文章做者:luxianghaohtml
文章来源:http://www.cnblogs.com/luxianghao/p/6807081.html 转载请注明,谢谢合做。nginx
免责声明:文章内容仅表明我的观点,若有不当,欢迎指正。正则表达式
syntax: rewrite regex replacement [flag] Default: — Context: server, location, if
rewrite ^/users/(.*)$ /show?user=$1? last;=
Syntax: proxy_pass URL; Default: — Context: location, if in location, limit_except
proxy_pass http://localhost:8000/uri/;
upstream backend { server backend1.example.com weight=5; server backend2.example.com:8080; server unix:/tmp/backend3; server backup1.example.com:8080 backup; server backup2.example.com:8080 backup; } server { location / { proxy_pass http://backend; } }
proxy_pass http://$host$uri;
server { listen 80; server_name example.com; proxy_read_timeout 120; proxy_send_timeout 120; include /etc/nginx/fastcgi_params; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log; location / { ... } }
location /name/ { proxy_pass http://127.0.0.1/remote/; } 请求http://example.com/name/test.html 会被代理到http://127.0.0.1/remote/test.html
location /name/ { proxy_pass http://127.0.0.1; } 请求http://example/name/test.html 会被代理到http://127.0.0.1/name/test.html
location /name/ { rewrite /name/([^/]+) /users?name=$1 break; proxy_pass http://127.0.0.1; }