How to setup as Nginx reverse proxy for Apache on Ubuntu for a domain

Having setup Nginx reverse proxy for Apache on Ubuntu the site is accessible by IP. With the domain name the page doesn't load. The DNS is fully propagated for the IP.

Need to mask the IP of Apache. Pinging the domain name reveals the IP of Apache server instead of Nginx.

Nginx is setup on one server and Apache on another both at different locations.

Below is the directive:

server_name example.com;
location / {
proxy_pass http://45.79.136.247:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

2 Replies

Linode Staff

Hi there,

I went ahead and added some tags to this post to give it more visibility to the Linode Community so more of our users can chime in with their input.

I also wanted to direct you to another post here on that gives some resources on this topic which may be helpful:

Install Nginx As Reverse Proxy Alongside Apache2

Thank you so much adding the tags.

Have already been through the links as with many others for the subject. All is good when running on the same server and IP.

But none of the written material addresses when servers are running on different IPs and communicating with each other, and also when connecting via domain names in lieu of IP addresses.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct