Welcome! Log In Create A New Profile

Advanced

Problem with reverse proxy cache & multiple vhosts

Posted by b5816414 
Problem with reverse proxy cache & multiple vhosts
June 27, 2011 04:50PM
Sup - I'm using Nginx to serve an Apache backend running multiple Vhosts on the same IP. Basically it works, still Nginx serves content for the first Vhost also for the second one and vise versa.

Nginx running in a Jail on 127.0.10.1 - Apache on 127.0.20.1.

Related configuration:

proxy_cache_path /tmp/site_aw levels=1:2 keys_zone=FIRST:75m inactive=24h max_size=1g;
proxy_cache_path /tmp/site_ptb levels=1:2 keys_zone=SECOND:75m inactive=2 4h max_size=1g;

Then the server configurations:

server {
listen 127.0.10.1:3128;
server_name proxy.example.com;
location / {
proxy_cache FIRST;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.20.1:80;
}
}
server {
listen 127.0.10.1:3128;
server_name proxy.othersite.com;
location / {
proxy_cache FIRST;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.20.1:80;
}
}

Well - this works though the second cache directory is never filled with anything. Also opening www.othersite.com opens the index of www,example.com. Opening unique content (for both domains) gets the content served without problems though.
Re: Problem with reverse proxy cache & multiple vhosts
June 28, 2011 07:11AM
Figured it out. :)

Problem was that I used internal hostnames for the 2 proxy caches - proxy.example.com and proxy.othersite.com.

Using the real domain names Apache serves "www.example.com" and "www.othersite.com" for the Nginx vhosts solved the problem. Of course then setting up the Apache backend by using IP's.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 68
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready