nginx 反向代理案例

时间:2021-11-09 21:06:38
server{
listen ssl;
server_name a.xxxxx.com;
root /home/wwwroot/default/asqumo;
ssl_protocols TLSv1. TLSv1. TLSv1;
ssl_certificate a.xxxxx.com.crt;
ssl_certificate_key a.xxxxx.com.key;
ssl_prefer_server_ciphers on; # access_log /home/wwwlogs/accesslog/xxxxx.log ;
location / {
if ($request_uri ~ ^/xxxxxx/) {
proxy_pass http://xxxxxx.sheep.xxxx.com;
} if ($request_uri ~ ^/xxxxxx/) {
proxy_pass http://xxxxxx.healxx.com;
} } location ~ .*\.(gif|jpg|jpeg|png|ico|bmp|swf|js|css|html)$
{
root /home/wwwroot/default/static/******/Public/;
expires 30d;
}
} server{
listen ;
server_name xxxxxx.xxxxx.com;
index index.html index.htm index.php;
root /home/wwwroot/default/xxxx/store/Public; #error_page /.html;
#include enable-php.conf;
include enable-php-pathinfo.conf;
location /nginx_status
{
stub_status on;
access_log off;
} location / {
if (!-e $request_filename) {
rewrite ^/xxxxxxxx/(.*)$ /api.php?s=$ last;
break;
rewrite ^(.*)$ /index.php?s=/$ last;
}
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/xxxxxx_access.log access;
}