upstream weplant { server 127.0.0.1:8000; server 127.0.0.1:7758; } upstream weplant_lisp { server 127.0.0.1:2020; } upstream weplant_popular { server 127.0.0.1:3000; } server { listen 80; server_name lisp.weplant.com; location / { proxy_pass http://weplant_lisp; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; } } server { listen 80; server_name popular.weplant.com; location / { proxy_pass http://weplant_popular; } } server { listen 80; listen 443; server_name ~(weplant|whz).(com|cn); # root /Users/Can/Develop/server; # location ~* /pictures/.*\..* { # root /Users/Can; # # try_files /$uri /$uri.jpg; # } add_header domain weplant.com; root /Users/Can/Develop/weplant/server/static; set $remote http://wohuizhong.com; location ~ /(?pictures/.*)/[^/]*$ { # Optimize it, no need for node.js ? May.7.2019 root /Users/Can/Develip/weplant; add_header host $host; add_header request-uri $request_uri; add_header request-xxx $http_user_agent; add_header http-host $http_host; add_header host-name $hostname; add_header uri $uri; return 301 $remote/$uri; # !! Important & so Useful!! # try_files $uri $uri.jpg $uri.jpeg $uri.png @missing; # /$dir/default.png /$dir/default.jpg; } location @missing { add_header missing $uri; return 302 $scheme://$host/$dir/default; # rewrite ^ http://$host/pictures/avatar/2130.png break; } location ~ ^/(?m/[^.]*)$ { rewrite ^ http://$host/$url.html; } location ~ ^/(mobile/post)/\d+$ { try_files $uri /mobile/post2.htm; } location ~ ^/post/(?[^.]*)$ { if ($http_user_agent ~* (android|iphone|ipad)) { rewrite ^ http://$host/mobile/post/$others break; } index index.htm; try_files $uri $uri/ /index.htm; } location ~ ^/lisp/(?.*)$ { proxy_pass http://weplant_lisp/$args; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; } location ~ ^/(api|socket\.io) { proxy_pass http://weplant; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass_header Server; # Hide server: ningx header proxy_redirect off; } location ~ ^/[^.]*$ { try_files $uri /index.htm; } # location / { # Optimize it, no need for node.js ? May.7.2019 # index index.htm; # root /Users/Can/Develop/server/static; # try_files $uri $uri.html $uri.html $uri/ /index.htm; # } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; # relative to nginx dir: /usr/local/nginx/ } }