1
pengfei 2015-10-10 12:53:16 +08:00 1
不知道另外加一个 location 块合不合用
'location ^~ /api {}' |
3
oott123 2015-10-10 13:02:57 +08:00 via Android 1
location / proxy_pass upstream1
location /api proxy_pass upstream2 |
6
yuchting 2015-10-10 13:12:06 +08:00 1
server {
listen 80; server_name www.ooooo.com; error_page 404 = /404.htm; location /f/fade_pay { proxy_pass http://xxxxx.com/fade_pay; proxy_set_header Host "xxxxx.com"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log off; error_log off; } location /f/fade_payok { proxy_pass http://yyyyy.com/fade_payok.html; proxy_set_header Host "yyyyy.com"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log off; error_log off; } location /f/test_fade_pay { proxy_pass http://zzzzz.com/fade_pay; proxy_set_header Host "zzzzz.com"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log off; error_log off; } 。。。。。。 } 我的反向代理服务器,只要备案一个域名,挂很多个服务器,端口可以任意。 不知道和题主的答案切合不切合。 |
7
salltm 2015-10-10 13:14:13 +08:00 1
..配置 server 的时候先写 /API 部分. 再写 /..
|
8
ryd994 2015-10-10 16:01:47 +08:00 1
|
10
ldehai OP @adexbn
@oott123 @pengfei @ryd994 @salltm @tan9le @yuchting 经测试,新增一个 location 可行,和顺序无关。配置如下: worker_processes 1; events { worker_connections 1024; } http { gzip on; #web server for cms upstream app { server 127.0.0.1:8000; server 127.0.0.1:8001; } #api server for app upstream api { server 127.0.0.1:9000; server 127.0.0.1:9001; } server { listen 80; location / { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_pass http://app; } location /api { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_pass http://api; } } } |
11
ldehai OP 多谢各位!
|