1. proxy_pass代理
server { location /a/ { proxy_pass http://www.baidu.com/; } location /b/ { proxy_pass http://www.163.com/; } }
注意:location和proxy_pass后面的/必须保留
2. rewrite代理
server { listen 80; server_name localhost; location / { root html; index index.html index.htm; try_files $uri /index.html; rewrite ^/a/(.*)$ https://a.com/$1 break; rewrite ^/b/(.*)$ https://b.com/app/$1 break; } }