nginx 代理多个个站点
1. proxy_pass代理
1.1 location和proxy_pass后面的/必须保留
1.2 proxy_pass后面的http://必须带上,不带会报404
server { location /a/ { proxy_pass http://www.baidu.com/; } location /b/ { proxy_pass http://www.163.com/; } }
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; } }