Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Nginx Reverse Proxy + Apache/Varnish

I recently setup an Apache-based server with about 3 virtual hosts/domains + Varnish on port 80. So let's say example1.com, example2.com and example3.com. Those are all hosted on ONE server. Now, I wanted to install a third party piece of software that also required to be on port 80. And if you only have 1 public IP, you can't point it towards specific servers inside of your DNS manager. That's why I wanted to setup an Nginx server with a reverse proxy, in order to use 1 port and point it towards the correct server.

After successfully setting up my Nginx server, I put this in:

server {
      server_name example1.com;
    
      location ~ {
        proxy_pass_header Authorization;
        proxy_pass http://example1.com;
        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_http_version 1.1;
        proxy_set_header Connection "";
        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 36000s;
        proxy_redirect off;
      }
    }

server {
      server_name example2.com;
    
      location ~ {
        proxy_pass_header Authorization;
        proxy_pass http://example2.com;
        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_http_version 1.1;
        proxy_set_header Connection "";
        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 36000s;
        proxy_redirect off;
      }
    }

server {
      server_name example3.com;
    
      location ~ {
        proxy_pass_header Authorization;
        proxy_pass http://example3.com;
        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_http_version 1.1;
        proxy_set_header Connection "";
        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 36000s;
        proxy_redirect off;
      }
    }

And inside /etc/hosts:

192.168.10.10 example1.com
192.168.10.10 example2.com
192.168.10.10 example3.com

After doing this, it technically works. But I don't think that this is the best solution. All the servers are on the same LAN, but since I have 3 virtual hosts, I can't just enter 192.168.10.10:443 as the proxy_pass I believe... Because the origin server wouldn't know which virtual host to serve? I've also thought about giving each virtual host on the origin server their own port, but I don't know if that is such a good idea. I know that Cloudflare also doesn't require you to make any changes to your origin server, so it shouldn't be required to completely overhaul your origin server.

If anyone has good suggestions to deal with this particular "problem", then thank you!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!