Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

Nginx in front of Apache: Only default server website is shown
Wednesday - Jun 18th 2014 - by - (0 comments)

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.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6938 Days
until Death of Computers
Why?