{"id":1600,"date":"2018-10-25T01:59:08","date_gmt":"2018-10-25T01:59:08","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1600"},"modified":"2018-10-25T02:25:20","modified_gmt":"2018-10-25T02:25:20","slug":"how-to-configure-a-nginx-reverse-proxy-with-apache","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/25\/how-to-configure-a-nginx-reverse-proxy-with-apache\/","title":{"rendered":"How To Configure A Nginx Reverse Proxy With Apache"},"content":{"rendered":"<p>Nginx can as a reverse proxy to Apache. Nginx does best at serving static content extremely fast whereas Apache can process dynamic content and use all of the various Apache modules and .htaccess that are typically the web standard of hosting. This guide assumes you already have a Apache installation and would like to add Nginx on top of it. If you still need to install Apache please see <a href=\"https:\/\/linuxadmin.io\/compile-apache-2-4-source\/\">https:\/\/linuxadmin.io\/compile-apache-2-4-source\/<\/a>. Essentially what you are using with this guide is using nginx as a media\/static content server and passing the rest of the requests to Apache. This combination can greatly improve performance over just a standard Apache web server.<\/p>\n<p>You will first need to install Nginx, this guide will walk you through <a href=\"https:\/\/linuxadmin.io\/nginx-compile-source\/\">compiling nginx from source<\/a>.<\/p>\n<h3>Setup Nginx Reverse Proxy<\/h3>\n<p>First edit the nginx configuration and add the following:<\/p>\n<p>server {<br \/>\nlisten 80;<\/p>\n<p>root \/var\/www\/html\/;<br \/>\nindex index.php index.html index.htm;<\/p>\n<p>server_name domain.com;<\/p>\n<p>location \/ {<br \/>\nroot \/var\/www\/html;<br \/>\nindex index.html index.htm;<br \/>\nproxy_pass http:\/\/127.0.0.1:8080;<br \/>\nproxy_redirect off;<br \/>\nproxy_read_timeout 1200;<br \/>\nproxy_send_timeout 1200;<br \/>\nproxy_connect_timeout 75;<br \/>\nproxy_set_header X-Real-IP $remote_addr;<br \/>\nproxy_set_header Host $host;<br \/>\n}<br \/>\nlocation ~* ^.+.(jpg|gif|jpeg|ico|avi|mpeg|mpg|wmv|png|css|js|xml)$ {<br \/>\nroot \/var\/www\/html;<br \/>\n}<br \/>\n}<\/p>\n<p>The proxy lines allow Nginx to to grab PHP or any other files from the Apache web server which you will reconfigure to run on port 8080. If a request matches the second location block (jpg|gif|ico|avi|mpeg|mpg|wmv|pgn|css|js|xml) it will be served directly by nginx, taking the load off the Apache web server.<\/p>\n<h3>Reconfigure Apache<\/h3>\n<p>You will then want to edit your Apache configuration<\/p>\n<p>vim \/etc\/httpd\/conf\/httpd.conf<\/p>\n<p>and replace<\/p>\n<p>Listen 80<\/p>\n<p>with<\/p>\n<p>Listen 8080<\/p>\n<p>You will also want to update any virtual hosts to no longer use port 80<\/p>\n<p>&lt;VirtualHost 192.168.1.100:80&gt;<\/p>\n<p>Should now become<\/p>\n<p>&lt;VirtualHost 127.0.0.1:8080&gt;<\/p>\n<p>This will allow Apache to bind on the local interface only serving local requests from Nginx.<\/p>\n<p>You will then want to restart both services to load the new configurations<\/p>\n<p>service httpd restartservice nginx restart<\/p>\n<p>Once you have completed that, Nginx will handle the initial request to port 80 and if a file type is not matched it will send it Apache to delivery the requested resource.<\/p>\n<p>May 23, 2017LinuxAdmin.io<\/p>\n<p><a href=\"https:\/\/linuxadmin.io\/nginx-reverse-proxy-apache-configuration\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nginx can as a reverse proxy to Apache. Nginx does best at serving static content extremely fast whereas Apache can process dynamic content and use all of the various Apache modules and .htaccess that are typically the web standard of hosting. This guide assumes you already have a Apache installation and would like to add &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/25\/how-to-configure-a-nginx-reverse-proxy-with-apache\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How To Configure A Nginx Reverse Proxy With Apache&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1600","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1600"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1600\/revisions"}],"predecessor-version":[{"id":1639,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1600\/revisions\/1639"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}