使用upstream必须配置下面参数加入location
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
--------------------
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream localhost {
#server 127.0.0.1:8886;
server 127.0.0.1:8889;
}
server {
listen 8888;
server_name localhost;
# add_header Access-Control-Allow-Credentials true;
# add_header Access-Control-Allow-Origin $http_origin;
location / {
# if ($request_method ~* "(GET|POST)") {
# add_header "Access-Control-Allow-Origin" *;
# }
# if ($request_method = OPTIONS ) {
# add_header "Access-Control-Allow-Origin" *;
# add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
# add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
# return 200;
# }
# proxy_pass http://60.191.221.43:8888;
proxy_pass http://localhost;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# location ~* \.(eot|ttf|woff)$ {
# add_header Access-Control-Allow-Origin '*';
#}
# location ~ \.(gif|jpg|png|js|css|txt)$ {
# root D:\orms\webapps\boot;
# index text.html index.htm;
# }
}
}
http {
upstream czbzshd {
server 127.0.0.1:8003 max_fails=3 fail_timeout=20s weight=1;
server 127.0.0.1:8009 max_fails=3 fail_timeout=20s weight=1;
}
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 80;
client_max_body_size 20m;
fastcgi_intercept_errors on;
server {
listen 8001;
server_name localhost;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
access_log D:/app/nginx-1.15.12/logs/8001/access_$year-$month-$day.log;
error_log D:/app/nginx-1.15.12/logs/8001/error.log;
location / {
root html;
index index.html index.htm;
proxy_pass http://czbzshd;
}
}
server {
listen 8002;
server_name localhost;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
access_log D:/app/nginx-1.15.12/logs/8002/access_$year-$month-$day.log;
error_log D:/app/nginx-1.15.12/logs/8002/error.log;
location /czbz8003/ {
proxy_pass http://127.0.0.1:8003/manager/status/;
}
location /czbz8006/ {
proxy_pass http://127.0.0.1:8006/manager/status/;
}
location /sfile/ {
alias D:/fileupload/;
}
location / {
proxy_pass http://127.0.0.1:8006/;
}
}
server {
listen 80;
server_name localhost;
error_page 502 /502.html;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
access_log D:/app/nginx-1.15.12/logs/80/access_$year-$month-$day.log;
error_log D:/app/nginx-1.15.12/logs/80/error.log;
location /wx/ {
proxy_pass http://127.0.0.1:8001/wx/;
}
location /css {
proxy_pass http://127.0.0.1:8001/css;
}
location /js {
proxy_pass http://127.0.0.1:8001/js;
}
location /images {
proxy_pass http://127.0.0.1:8001/images;
}
location /plugins {
proxy_pass http://127.0.0.1:8001/plugins;
}
location = /502.html {
root D:/app/nginx-1.15.12/html;
}
location / {
root D:/app/czbzsb;
try_files $uri $uri/ /index.html =404;
}
}
}

被折叠的 条评论
为什么被折叠?



