Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda