{"id":88905,"date":"2020-07-16T07:42:06","date_gmt":"2020-07-16T05:42:06","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/apache-nginx-svyazany-odnoj-czepyu"},"modified":"2020-07-16T07:42:06","modified_gmt":"2020-07-16T05:42:06","slug":"apache-nginx-svyazany-odnoj-czepyu","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/apache-nginx-svyazany-odnoj-czepyu","title":{"rendered":"Apache &amp; Nginx. Linked in a chain","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><i>How the Apache &amp; Nginx Combination Works in Timeweb<\/i><\/p>\n<p>For many companies, Nginx + Apache + PHP is a very typical and widely used combination, and Timeweb is no exception. However, understanding exactly how it is implemented can be interesting and useful. <\/p>\n<p><img decoding=\"async\" alt=\"Apache &amp; Nginx. Linked in a chain\" src=\"\/wp-content\/uploads\/2020\/07\/2d22a78f35b7f46c260ed4ece2d9eb46.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nUsing such a combination is certainly dictated by the needs of our clients. Both Nginx and Apache play special roles, each solving specific tasks.<\/p>\n<p>Main Settings <b>Apache<\/b> are performed in the configuration files of Apache itself, while settings for client sites occur through <b>the .htaccess file.<\/b>.htaccess is a configuration file where the client can independently set rules and behaviors for the web server. Such settings will specifically relate to their site. For example, thanks to Apache's functionality, users can change the operating mode within one version of PHP from mod_php to mod_cgi; redirects, SEO optimization, user-friendly URLs, and certain PHP limits can be configured.<\/p>\n<p><b>Nginx<\/b> is used as a proxy server to redirect traffic to Apache and as a <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/en\/server\/\"   title=\"web server\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"1156\">web server<\/a> to serve static content. We have also developed security modules for Nginx that allow us to protect our users' data, for instance, by segmenting access rights. <\/p>\n<p>Let's imagine that a user visits our client's website. First, the user hits Nginx, which serves static content. This happens instantly. Then, when it comes to loading PHP, Nginx redirects the request to Apache. Apache, in conjunction with PHP, then generates dynamic content.<\/p>\n<h3>Features of the Apache &amp; Nginx Combination in Timeweb <\/h3>\n<p>\nOur virtual hosting implements 2 main operating schemes for Apache &amp; Nginx: <b>Shared and Dedicated.<\/b>.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n<b>Shared Scheme<\/b><\/p>\n<p>This scheme is used for most users. It is characterized by simplicity and resource efficiency: the Shared scheme uses fewer resources, which makes its tariff cheaper. According to this scheme, one Nginx is running on the server, which can handle all user requests, along with several instances of Apache.<\/p>\n<p>The Shared scheme has been improved over a long period: gradually, we fixed deficiencies. It is convenient that it can be done without the need to modify the source code.<\/p>\n<p><img decoding=\"async\" alt=\"Apache &amp; Nginx. Linked in a chain\" src=\"\/wp-content\/uploads\/2020\/07\/69fc0dfaa26a8d289116435879bc7dbb.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>the Shared scheme. <\/i><\/p>\n<p><b>Dedicated Scheme.<\/b><\/p>\n<p>Dedicated requires more resources, which is why its pricing is higher for clients. In the Dedicated scheme, a separate Apache instance is launched for each client. Resources are reserved exclusively for the client. Here's how it works: the server hosts multiple PHP versions. We support versions 5.3, 5.4, 5.6, 7.1, 7.2, 7.3, 7.4. Thus, a separate Apache is started for each PHP version.<\/p>\n<p><img decoding=\"async\" alt=\"Apache &amp; Nginx. Linked in a chain\" src=\"\/wp-content\/uploads\/2020\/07\/1ad6ea3651d18718afe43aa111d030a4.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>Dedicated scheme<\/i><\/p>\n<h3>Safe zone. Configuring zones in Nginx<\/h3>\n<p>\nPreviously, we used many shared memory zones (zone) for Nginx\u2014one server block for each domain. This configuration requires significant resources, as a separate zone is created for each website. However, in Nginx settings, most websites are similar, allowing them to fit into a single zone by using the map directive in the module <b>ngx_http_map_module<\/b>, which allows for mappings to be defined. For example, we have a zone template where we must provide variables: the path to the site, the PHP version, and the user. This has sped up the reading of Nginx configuration, meaning a reload is faster.<\/p>\n<p>This kind of configuration has significantly saved memory resources and improved Nginx performance.<\/p>\n<h3>Reload failed! <\/h3>\n<p>\nIn the Shared scheme, we eliminated the need to reload Apache when making changes to site settings. Previously, when a client wanted to add a domain or change the PHP version, a mandatory Apache reload was required, leading to delays in responses and negatively impacting site performance.<\/p>\n<p>We eliminated reloads by creating dynamic configurations. Thanks to <noindex><a rel=\"nofollow\" href=\"http:\/\/mpm-itk.sesse.net\/\">mpm-itk<\/a><\/noindex> (the Apache module), each process runs under a separate user, enhancing security. This method allows passing user and document_root data from Nginx to Apache2. Thus, Apache does not contain site configurations within itself; it receives them dynamically, and reloads are no longer necessary.<\/p>\n<p><img decoding=\"async\" alt=\"Apache &amp; Nginx. Linked in a chain\" src=\"\/wp-content\/uploads\/2020\/07\/6f033a26459b4448a5df80fef7efd36e.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>Configuration of the Shared scheme<\/i> <\/p>\n<h3>What about Docker?<\/h3>\n<p>\nMany companies have transitioned to container-based systems. Timeweb is currently considering such a transition. Certainly, every solution has its pros and cons. <\/p>\n<p>Along with undeniable advantages, a container system provides the user with fewer resources. At Timeweb, thanks to the described hosting operation scheme, there is no limit on RAM for the user. They receive more resources than in a container. Furthermore, the user can have more Apache modules loaded.<\/p>\n<p>Timeweb supports around 500,000 websites. We bear great responsibility and do not introduce immediate, unwarranted changes to the complex architecture. The combination of Apache &amp; Nginx is reliable and time-tested. We, in turn, strive to achieve maximum performance through unique configurations.<\/p>\n<p>To ensure the quality and speed of operation for a large number of websites, it is necessary to use a template and dynamic configuration of Apache and Nginx. This allows for simple and quick administration of a large number of similar servers.<br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/510896\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 Apache &amp; Nginx \u0432 Timeweb \u0414\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 Nginx + Apache + PHP \u2014 \u043e\u0447\u0435\u043d\u044c \u0442\u0438\u043f\u043e\u0432\u0430\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u043a\u0430, \u0438 Timeweb \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0441\u0442\u0430\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u043e\u0434\u0438\u043a\u0442\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043d\u0430\u0448\u0438\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432. \u0418 Nginx \u0438 Apache \u0438\u0433\u0440\u0430\u044e\u0442 \u043e\u0441\u043e\u0431\u0443\u044e \u0440\u043e\u043b\u044c, \u043a\u0430\u0436\u0434\u044b\u0439 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":88906,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-88905","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 Apache &amp; Nginx \u0432 Timeweb \u0414\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 Nginx + Apache + PHP \u2014 \u043e\u0447\u0435\u043d\u044c \u0442\u0438\u043f\u043e\u0432\u0430\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u043a\u0430, \u0438 Timeweb \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0441\u0442\u0430\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/apache-nginx-svyazany-odnoj-czepyu\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47Apache &amp; Nginx. \u0421\u0432\u044f\u0437\u0430\u043d\u044b \u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043f\u044c\u044e | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 Apache &amp; Nginx \u0432 Timeweb \u0414\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 Nginx + Apache + PHP \u2014 \u043e\u0447\u0435\u043d\u044c \u0442\u0438\u043f\u043e\u0432\u0430\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u043a\u0430, \u0438 Timeweb \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0441\u0442\u0430\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/apache-nginx-svyazany-odnoj-czepyu\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-07-16T05:42:06+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-07-16T05:42:06+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Apache &amp; Nginx. Linked in a chain | ProHoster","description":"How the Apache &amp; Nginx combination is implemented at Timeweb For many companies, Nginx + Apache + PHP is a very typical and widespread combination, and Timeweb is no exception.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/apache-nginx-svyazany-odnoj-czepyu","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47Apache &amp; Nginx. \u0421\u0432\u044f\u0437\u0430\u043d\u044b \u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043f\u044c\u044e | ProHoster","og:description":"\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 Apache &amp; Nginx \u0432 Timeweb \u0414\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 Nginx + Apache + PHP \u2014 \u043e\u0447\u0435\u043d\u044c \u0442\u0438\u043f\u043e\u0432\u0430\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u043a\u0430, \u0438 Timeweb \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0441\u0442\u0430\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/apache-nginx-svyazany-odnoj-czepyu","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-07-16T05:42:06+00:00","article:modified_time":"2020-07-16T05:42:06+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"88905","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 13:20:24","updated":"2026-02-09 15:05:02","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/88905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=88905"}],"version-history":[{"count":1,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/88905\/revisions"}],"predecessor-version":[{"id":158359,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/88905\/revisions\/158359"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/88906"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=88905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=88905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=88905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}