#虽然都是location但是是有区别的
#设置首页
Location =/{
Proxy_pass http://127.0.0.1/site/eshop/home.html;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
#反向代理
Location/{
#root/site/eshop/;
#index home.html;
Proxy_pass http://127.0.0.1:7001;
Rewrite (. *) \.html$ $1.jsp;
}
Full Setup Example
server {
Listen 80;
server_name 115.28.x.x;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location =/{
Proxy_pass http://127.0.0.1/site/eshop/home.html;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
Location/{
#root/site/eshop/;
#index home.html;
Proxy_pass http://127.0.0.1:7001;
Rewrite (. *) \.html$ $1.jsp;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# Proxy_pass http://127.0.0.1;
#}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root HTML;
# Fastcgi_pass 127.0.0.1:9000;
# Fastcgi_index index.php;
# Fastcgi_param Script_filename/scripts$fastcgi_script_name;
# include Fastcgi_params;
#}
# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
#
#location ~/\.ht {
# Deny All;
#}
}
Nginx Configuration Site default home page, pseudo-static JSP and multi-server reverse proxy