1 upstream nodejs-pc { 2 server localhost:17180; 3 keepalive 64; 4 } 5 6 upstream fpm_backend { 7 server unix:/dev/shm/php-fpm.sock; 8 } 9 10 upstream nodejs-mobile { 11 server localhost:17181; 12 keepalive 64; 13 } 14 15 16 #-------------------------------------------------------- 17 # 18 # 19 #-------------------------------------------------------- 20 server { 21 listen 80; 22 server_name ; 23 24 set $webroot "/www"; 25 26 root $webroot/cn_2018/frontend/web; 27 28 include /www/config/UrlRedirect.maplst; 29 30 location ^~ /_front/ { 31 proxy_pass http://localhost:9100/; 32 } 33 34 location ^~ /_mfront/ { 35 proxy_pass http://localhost:9200/; 36 } 37 38 location = /mobile/pay/ios-orders { 39 try_files $uri $uri/ /index.php$is_args$args; 40 } 41 42 location ^~ /cn-api { 43 try_files $uri $uri/ /index.php$is_args$args; 44 } 45 46 location ^~ /upload { 47 try_files $uri $uri/ error=404; 48 } 49 50 location ~ ^/(campus|css|js|images|public|dist|upload|bower_components) { 51 proxy_pass http://localhost:9000; 52 add_header X-P phpnode; 53 } 54 55 56 location / { 57 proxy_redirect off; 58 proxy_set_header Host $host; 59 proxy_set_header X-Real-IP $remote_addr; 60 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 61 proxy_set_header X-NginX-Proxy true; 62 client_max_body_size 256m; 63 proxy_set_header Connection ""; 64 proxy_http_version 1.1; 65 66 if ($http_user_agent ~* "iphone|android") { 67 proxy_pass http://nodejs-mobile; 68 } 69 70 proxy_pass http://nodejs-pc; 71 72 if ($requriphp) { 73 proxy_pass http://localhost:9000; 74 add_header X-P phpnode; 75 } 76 77 } 78 79 location ~ \.php$ { 80 include fastcgi_params; 81 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 82 fastcgi_pass fpm_backend; 83 fastcgi_keep_conn on; 84 } 85 86 87 88 89 90 access_log /wwwlogs/nginx/request-uri-php.log access if=$requriphp; 91 92 93 94 95 } 96 97 #-------------------------------------------------------- 98 # 127.0.0.1:9000 99 # proxy php 100 #-------------------------------------------------------- 101 102 server 103 { 104 listen 9000; 105 server_name 127.0.0.1; 106 index index.html index.htm index.php default.html default.htm default.php; 107 108 set $webroot "/www"; 109 root $webroot/cn_2018/frontend/web; 110 111 location / { 112 try_files $uri $uri/ /index.php$is_args$args; 113 } 114 115 location ~ \.php$ { 116 include fastcgi_params; 117 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 118 fastcgi_pass fpm_backend; 119 fastcgi_keep_conn on; 120 try_files $uri =404; 121 } 122 123 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js|json|inf|woff|ttf|woff2|map|ini|temp|dll|DLL|txt|log|manifest|sys|xml|ico|cat|zip|sh|data|apk|exe|dat)$ 124 { 125 expires 3d; 126 } 127 128 location ~ .*\.(json|inf)$ 129 { 130 expires 0; 131 } 132 error_log /wwwlogs/nginx/9000-error.log; 133 access_log /wwwlogs/nginx/9000-access.log access; 134 } 135 136 #-------------------------------------------------------- 137 # 127.0.0.1:9100 138 # proxy front 139 #-------------------------------------------------------- 140 141 server 142 { 143 listen 9100; 144 server_name 127.0.0.1; 145 index index.html index.htm index.php default.html default.htm default.php; 146 147 set $webroot "/www"; 148 root $webroot/cn_2018_fe/.nuxt/dist; 149 150 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js|json|inf|woff|ttf|woff2|map|ini|temp|dll|DLL|txt|log|manifest|sys|xml|ico|cat|zip|sh|data|apk|exe|dat)$ 151 { 152 #为了保证 新就 资源文件都能找到 加个备用代理 153 try_files $uri @cn_fe_2; 154 expires 3d; 155 } 156 157 location @cn_fe_2 { 158 proxy_pass http://localhost:9101; 159 } 160 161 location ~ .*\.(json|inf)$ 162 { 163 expires 0; 164 } 165 error_log /wwwlogs/nginx/9100-error.log; 166 access_log /wwwlogs/nginx/9100-access.log access; 167 } 168 server 169 { 170 listen 9101; 171 server_name 127.0.0.1; 172 index index.html index.htm index.php default.html default.htm default.php; 173 174 set $webroot "/www"; 175 root $webroot/cn_2018_fe_2/.nuxt/dist; 176 177 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js|json|inf|woff|ttf|woff2|map|ini|temp|dll|DLL|txt|log|manifest|sys|xml|ico|cat|zip|sh|data|apk|exe|dat)$ 178 { 179 try_files $uri =404; 180 expires 3d; 181 } 182 183 location ~ .*\.(json|inf)$ 184 { 185 expires 0; 186 } 187 error_log /wwwlogs/nginx/9101-error.log; 188 access_log /wwwlogs/nginx/9101-access.log access; 189 } 190 191 192 #-------------------------------------------------------- 193 # 127.0.0.1:9200 194 # proxy mobile front 195 #-------------------------------------------------------- 196 197 server 198 { 199 listen 9200; 200 server_name 127.0.0.1; 201 index index.html index.htm index.php default.html default.htm default.php; 202 203 set $webroot "/www"; 204 root $webroot/cn_2018_fe_mobile/.nuxt/dist; 205 206 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js|json|inf|woff|ttf|woff2|map|ini|temp|dll|DLL|txt|log|manifest|sys|xml|ico|cat|zip|sh|data|apk|exe|dat)$ 207 { 208 try_files $uri @cn_fe_mobile_2; 209 expires 3d; 210 } 211 212 location @cn_fe_mobile_2 { 213 proxy_pass http://localhost:9201; 214 } 215 216 location ~ .*\.(json|inf)$ 217 { 218 expires 0; 219 } 220 error_log /wwwlogs/nginx/9200-error.log; 221 access_log /wwwlogs/nginx/9200-access.log access; 222 } 223 server 224 { 225 listen 9200; 226 server_name 127.0.0.1; 227 index index.html index.htm index.php default.html default.htm default.php; 228 229 set $webroot "/www"; 230 root $webroot/cn_2018_fe_mobile_2/.nuxt/dist; 231 232 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js|json|inf|woff|ttf|woff2|map|ini|temp|dll|DLL|txt|log|manifest|sys|xml|ico|cat|zip|sh|data|apk|exe|dat)$ 233 { 234 try_files $uri =404; 235 expires 3d; 236 } 237 238 location ~ .*\.(json|inf)$ 239 { 240 expires 0; 241 } 242 error_log /wwwlogs/nginx/9201-error.log; 243 access_log /wwwlogs/nginx/9201-access.log access; 244 }