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

323
Visualizações
How to forward servername to nested Apache VirtualHost?
  • NAS: QNAP
  • Docker Image: php:8.0-apache

I have a NAS with numerous dockerised services with domains all pointing to the NAS with Apache reverse proxies set up to direct to the correct Docker Container IP:PORT.

All of this works great.

I decided to challenge myself by adding a container to host all my toy websites but I can't figure out how to set up the reverse proxy so the ServerName in the NAS Apache VirtualHost is forwarded to the container's Apache VirtualHost to direct to the correct folder.

The site lives in a folder on the NAS /share/dev/web/sites.

With configs below, I can browse to http://sites.mydomain.com/sites whereas what I want to be able to do is visit http://sites.mydomain.com.

I think that my NAS Apache VirtualHost is not forwarding the servername so the Docker Container Apache VirtualHost doesn't know how to filter the traffic.

I've tried a number of different apache settings with no luck, could anyone point the way?

docker-compose

version: '3.8'
services:
  php-apache-environment:
    container_name: php-apache
    image: php:8.0-apache
    volumes:
      - /share/dev/web:/var/www/html/
      - /share/dev/docker-composer/php/apache/apache2.conf:/etc/apache2/apache2.conf
      - /share/dev/docker-composer/php/apache/custom.conf:/etc/apache2/sites-available/custom.conf
    ports:
      - 9103:80

NAS Apache VirtualHost

<VirtualHost *:80>
    ServerName sites.mydomain.com
    ProxyPass / http://192.168.253.53:9103/
    ProxyPassReverse / http://192.168.253.53:9103/
</VirtualHost>

Docker Container Apache VirtualHost

<VirtualHost *:80>
  ServerName sites.mydomain.com

  ServerAdmin webmaster@name
  DocumentRoot /var/www/html/sites

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You want ProxyPreserveHost

When enabled, this option will pass the Host: line from the incoming request to the proxied host, instead of the hostname specified in the ProxyPass line.

This option should normally be turned Off. It is mostly useful in special configurations like proxied mass name-based virtual hosting, where the original Host header needs to be evaluated by the backend server.

For your config, something like:

 <VirtualHost *:80>
    ServerName sites.mydomain.com
    ProxyPreserveHost on
    ProxyPass / http://192.168.253.53:9103/
    ProxyPassReverse / http://192.168.253.53:9103/
</VirtualHost>
over 4 years ago · Santiago Trujillo Relatório
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