Answer the question
In order to leave comments, you need to log in
How to set up 1 nginx for many Apaches?
Hello,
I want to set up nginx as a proxy for Apache.
On Apache (hanging on port 8080), I have many virtual hosts (domains) installed, all on the same ip.
Is it possible to somehow "globally" configure nginx so that we don't have to create a separate server block for each host?
For example, if I have all these sites in folders by host name:
/var/www/mydomain.com/
/var/www/otherdomain.org/
...
Nginx will only have to return static, and send all other requests to Apache ( while passing the correct parameters, etc.)
If such a configuration is possible - do you think there could be any potential problems with it?
Thank you!
PS
For the admin panel, ISPconfig is used if anything (tied to Apache)
Answer the question
In order to leave comments, you need to log in
server {
listen 80 default;
disable_symlinks if_not_owner from=$root_path;
set $root_path /var/www/$http_host;
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root $root_path;
error_page 404 = @fallback;
}
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
}
It's easier to proxy pass everything and set up the cache normally in the PACE proxy
Nginx will have to give only static, and send all other requests to Apache (while passing the correct parameters, etc.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question