Reverse Proxy?
-
So, I have 1 fixed IP address, and 2 webservers, both running on port 80.
I want subdomain #1 to resolve to server #1, and have subdoman #2 resolve to server #2.
I have been researching this, and it seems I can do this, if I setup a reverse proxy on port 80.
Anyone every do anything like this before?
-
I know it can be relatively easily done with Apache or Nginx. It has been a long time since I've done it with Apache, and I've never done it with Nginx.
-
I do this with NGinX all the time, it is the primary use of NGinX. Apache will do it too, I just don't use it for that very often.
But before we go down the rabbit hole let's be sure this is the right approach. Why is it that you have two web servers? Are these actually two different VMs? Or two web servers on one VM?
-
Yes, two different VM's.
The problem is I need to run a web server, and screenconnect on the same domain, both using port 80.
-
@anonymous said:
Yes, two different VM's.
The problem is I need to run a web server, and screenconnect on the same domain, both using port 80.
Okay, that makes sense then. I would just use NGinX for this, it is famously built for this usage and extreme efficient at it (and easy to set up.) You are reading this and responding to this via an NGinX Reverse Proxy doing exactly what you describe.
-
@scottalanmiller Thanks! I am looking for some kinda of step by step guide to get me started. Any ideas? I have googled, but I don't see much
-
A bit busy at the moment but I can grab some code samples for you shortly.
Are you going to install NGinX to a new VM (vny-lnx-rprox) or to one of the same VMs as one of the other services?
-
@scottalanmiller I would think it would make since to add it on my webserver? If not, I have made a new VM too. What would you do?
-
-
@anonymous said:
@scottalanmiller I would think it would make since to add it on my webserver? If not, I have made a new VM too. What would you do?
What is the web server currently doing? Is it an Apache node?
-
@scottalanmiller basic LAMP stack running WordPress for 5 domains using virtual hosts.
-
Okay. To put NGinX on there, you will need to move Apache to another port. Say 8080, for example. NGinX will get 80 and will then basically do NAT for you to 8080.
-
-
Here is a sample of a site config from the /etc/nginx/sites-available folder on Ubuntu 15.04.
cat yoursitename.conf server { client_max_body_size 40M; listen 80; server_name www.yoursitename.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8080/; proxy_redirect off; } }
127.0.0.1 is because this is the one running on the same machine. If you need to point to one on a different VM, just put the VM's IP address in that spot.
-
I see a bunch of fields here. The only ones I would need to edit is server_name and proxy_pass?
Then just copy and paste to create more sites?
-
@anonymous said:
I see a bunch of fields here. The only ones I would need to edit is server_name and proxy_pass?
Then just copy and paste to create more sites?
Correct.
-
I hate searching this site...
I swear there was a thread with a walk through on setting up nginx as a proxy for multiple servers....
Anyone know where it is?