nginx反向代理

#user nobody;
worker_processes 1;

events {
worker_connections 1024;
}


http{
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

include mime.types;
default_type application/octet-stream;
#上传文件大小
client_max_body_size 300m;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"' '$upstream_addr';


log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'$upstream_addr $upstream_response_time $request_time';
access_log /logs/access.log main;

sendfile on;

keepalive_timeout 65;

fastcgi_connect_timeout 600;

server {
listen 8089;
server_name 172.30.66.115;
#server_name jyyytest.19ego.cn;

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
location / {
root /app/yunying/frontPage/ ;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /api { #添加访问目录为/apis的代理配置
proxy_connect_timeout 600s;
add_header 'Access-Control-Allow-Origin' '*';
rewrite ^/(.*)$ /$1 break;
#proxy_pass http://172.17.230.15:8086;
proxy_pass http://172.30.66.115:8086;
}
location /istatic {
root /app/yunying;
autoindex on;
}
}

server {
listen 8080;
server_name www.test.com;

location / {
root /app/antoil/front;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /api { #添加访问目录为/apis的代理配置
rewrite ^/(.*)$ /$1 break;
proxy_pass http://172.30.66.115:9999;
chunked_transfer_encoding off;
}

}
}

原文地址:https://www.cnblogs.com/liangmm/p/11647666.html