Welcome! Log In Create A New Profile

Advanced

reverse proxy - vhosts setup

Posted by agriz 
reverse proxy - vhosts setup
March 15, 2012 06:07AM
hi

I want to have nginx and apache to serve static an dynamic files separately.

I added this in apache

<VirtualHost *:8080>
ServerAdmin info@server1.com
DocumentRoot /var/www/html/server1
ServerName www.server1.com
ErrorLog /etc/httpd/logs/server1.error.log
CustomLog /etc/httpd/logs/server1.access.log common
</VirtualHost>

<VirtualHost *:8080>
ServerAdmin info@server2.com
DocumentRoot /var/www/html/server2
ServerName www.server2.com
ErrorLog /etc/httpd/logs/server2.error.log
CustomLog /etc/httpd/logs/server2.access.log common
</VirtualHost>

in nginx.config i added the following

server {
listen 80;
server_name www.server2.com server2.com;

#access_log logs/host.access.log main;
error_log /var/log/nginx/server2.error.log;
access_log /var/log/nginx/server2.access.log;
location / {
proxy_pass http://127.0.0.1:8080;
root /var/www/html/server2;
index index.html index.htm index.php;
}

error_page 404 /404.php;
location = /404.php {
proxy_pass http://127.0.0.1:8080;
root /var/www/html/server2;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.php;
location = /50x.php {
proxy_pass http://127.0.0.1:8080;
root /var/www/html/server2;
}

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js)$ {root /var/www/html;}
}

i added another one for server1.com

Now will it work properly?
In all virtual hosts, i have this
proxy_pass http://127.0.0.1:8080;

Is that okay?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 238
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