{"id":52,"date":"2023-02-22T05:02:03","date_gmt":"2023-02-22T05:02:03","guid":{"rendered":"https:\/\/smartsource.com.sg\/blog\/?p=52"},"modified":"2023-02-22T05:02:29","modified_gmt":"2023-02-22T05:02:29","slug":"use-nginx-as-reverse-proxy-to-apache","status":"publish","type":"post","link":"https:\/\/smartsource.com.sg\/blog\/index.php\/2023\/02\/22\/use-nginx-as-reverse-proxy-to-apache\/","title":{"rendered":"Use nginx as reverse proxy to apache"},"content":{"rendered":"<p>Consider you have an application running in apache using port 8080. And you have nginx running on the same server listening to port 80. You can then use nginx as reverse proxy to forward requests internally to apache.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>#Step 1. create a config file\nsudo vim  \/etc\/nginx\/sites-available\/apache\n\r\n#Step 2. copy paste the below lines in that config file.\nserver {\r\n    listen 80;\r\n    server_name yourdomain.com www.yourdomain.com;\r\n\r\n    location \/ {\r\n        proxy_pass http:\/\/localhost:8080;\r\n        proxy_set_header Host $host;\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_set_header X-Forwarded-Proto $scheme;\r\n    }\r\n}\r\n\r\n#Step 3: enable the newly created configuration\nsudo ln -s \/etc\/nginx\/sites-available\/apache \/etc\/nginx\/sites-enabled\/apache\r\n\r\n#Step 4: Restart nginx\nsudo nginx -t\r\nsudo systemctl reload nginx<\/code><\/pre>\n\n\n\n<p>Assuming your apache is already running in port 8080, users accessing yourdomain.com will now be automatically forwarded to apache to server the requests.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Consider you have an application running in apache using port 8080. And you have nginx running on the same server listening to port 80. You can then use nginx as&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[14,37,38],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-apache","tag-nginx","tag-reverse-proxy"],"_links":{"self":[{"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":1,"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions\/53"}],"wp:attachment":[{"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smartsource.com.sg\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}