Nginx in front of Apache: Only default server website is shown

Written by - 0 comments

Published on - Listed in Linux Internet Nginx Apache


Had a weird case, where an Nginx is in front of an Apache web server and whenever I tried to access the website through the Nginx, the Apache's default website was shown instead of the virtual hosts website.

I had the following config in Nginx:

server {
  listen 80;
  server_name vhost.example.com;

  location / {
    include /etc/nginx/proxy.conf;
    proxy_set_header Host $host;
    proxy_pass http://apache:80;
  }
}

The reason for this weird effect is that I already had "proxy_set_header" defined in the included config file proxy.conf. It seems that if it is defined twice, the host name gets lost and therefore Apache in the backend only serves the default server's website.

I have double-checked and verified this with these combinations:

  • Debian Wheezy, Nginx 1.2.1, Apache 2.2.22
  • Ubuntu 14.04, Nginx 1.4.6, Apache 2.4.7

After removing the additional "proxy_set_header" definition, the correct website for vhost.example.com was shown.




Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Icingaweb   Icingaweb2   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder   


Update cookies preferences