前言

什么是 nginx ? nginx 主要的用在哪里?
后端的小伙伴可能了解的比较多,前端的同学们表示不服,也要学习一波,感受下它的强大之处~~

定义

nginx :静态资源服务器,一般用做 负载均衡 和 反向代理 。

下载

下载地址:nginx下载地址
根据自己的需求下载相应版本的 nginx zip 文件。

配置

事先准备要配置nginx的 云服务器 ,具体可以购买阿里云服务器,详情移步阿里云
下面按照 aq-nacos-1 这台服务器为例:

  1. 目录结构以及位置

    cd usr/soft
    企业微信截图_16273700199052.png
    企业微信截图_16273706827193.png

  2. nginx.conf配置信息

    不带端口的配置: ```json user root;

    user nobody;

    worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events { worker_connections 1024; }

http { include mime.types; default_type application/octet-stream;

  1. #client_max_body_size 50m;
  2. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  3. # '$status $body_bytes_sent "$http_referer" '
  4. # '"$http_user_agent" "$http_x_forwarded_for"';
  5. #access_log logs/access.log main;
  6. sendfile on;
  7. #tcp_nopush on;
  8. #keepalive_timeout 0;
  9. keepalive_timeout 65;

gzip on; gzip_min_length 1k; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary on; client_max_body_size 1024m; #允许客户端请求的最大单文件字节数 client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数

  1. #gzip on;
  2. upstream api-gateway {
  3. server 127.0.0.1:13000;
  4. server 172.26.224.77:13000;
  5. }
  6. server {
  7. listen 80;
  8. server_name api.v2.daruiyun.com;
  9. location ^~ /ccb/app/api/ {
  10. proxy_pass http://api-gateway/ccb/app/api/;
  11. }
  12. }
  13. server {
  14. listen 80;
  15. server_name bes.aiqin.com;
  16. proxy_buffer_size 512k;
  17. proxy_buffers 16 512k;
  18. proxy_set_header Host $host:$server_port;
  19. proxy_set_header X-Real-IP $remote_addr;
  20. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  21. proxy_set_header X-Forwarded-Proto $scheme;
  22. proxy_read_timeout 3600;
  23. proxy_send_timeout 3600;
  24. location ^~ /bpm/api/ {
  25. proxy_pass http://api-gateway/bpm/api/;
  26. }
  27. location ^~ /bes/api/ {
  28. proxy_pass http://api-gateway/bes/web/;
  29. }
  30. location ^~ /bpmn/ {
  31. expires -1s;
  32. add_header Cache-Control no-cache;
  33. add_header Cache-Control private;
  34. alias /usr/fuwushe/html/bpm/;
  35. index index.html index.htm;
  36. }
  37. location / {
  38. expires -1s;
  39. add_header Cache-Control no-cache;
  40. add_header Cache-Control private;
  41. alias /usr/fuwushe/html/bes/;
  42. index index.html index.htm;
  43. try_files $uri $uri/ /index.html;
  44. }
  45. }
  46. server {
  47. listen 80;
  48. server_name bpm.dingtalk.aiqin.com;
  49. proxy_buffer_size 512k;
  50. proxy_buffers 16 512k;
  51. proxy_set_header Host $host:$server_port;
  52. proxy_set_header X-Real-IP $remote_addr;
  53. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  54. proxy_set_header X-Forwarded-Proto $scheme;
  55. proxy_read_timeout 3600;
  56. proxy_send_timeout 3600;
  57. location ^~ /bpm/api/ {
  58. proxy_pass http://127.0.0.1:13000/bpm/api/;
  59. }
  60. location ^~ /bes/api/ {
  61. proxy_pass http://127.0.0.1:13000/bes/web/;
  62. }
  63. location ^~ /dingtalk/api/ {
  64. proxy_pass http://127.0.0.1:13000/dingtalk/web/;
  65. }
  66. location / {
  67. expires -1s;
  68. add_header Cache-Control no-cache;
  69. add_header Cache-Control private;
  70. alias /usr/fuwushe/html/bpm_flaw/;
  71. index index.html index.htm;
  72. try_files $uri $uri/ /index.html; #这里必须加这个try_files,不然空白
  73. }
  74. }
  75. server {
  76. listen 80;
  77. server_name bpm.aiqin.com;

proxy_buffer_size 512k; proxy_buffers 16 512k;

  1. proxy_set_header Host $host:$server_port;
  2. proxy_set_header X-Real-IP $remote_addr;
  3. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  4. proxy_set_header X-Forwarded-Proto $scheme;
  5. proxy_read_timeout 3600;
  6. proxy_send_timeout 3600;
  7. location ^~ /bpm/api/ {
  8. proxy_pass http://api-gateway/bpm/api/;
  9. }
  10. location ^~ /bpm/api/auth/ {
  11. proxy_pass http://api-gateway/bpm/api/auth/;
  12. }
  13. location ^~ /dingtalk/api/ {
  14. proxy_pass http://api-gateway/dingtalk/web/;
  15. }
  16. location / {
  17. expires -1s;
  18. add_header Cache-Control no-cache;
  19. add_header Cache-Control private;
  20. alias /usr/fuwushe/html/bpm/;
  21. index index.html index.htm;
  22. try_files $uri $uri/ /index.html;
  23. }
  24. }
  25. server {
  26. listen 80;
  27. server_name hms.aiqin.com;
  28. location ^~ /api/auth/ {
  29. proxy_pass http://api-gateway/dls/web/mall/auth/;
  30. }
  31. location ^~ /api/dls/ {
  32. proxy_pass http://api-gateway/dls/web/mall/;
  33. }
  34. location ^~ /dl/tls/api/ {
  35. proxy_pass http://api-gateway/tlsopen/;
  36. }
  37. location ^~ /dl/tms/api/ {
  38. proxy_pass http://api-gateway/tmsopen/;
  39. }
  40. location ^~ /dl/material/api/ {
  41. proxy_pass http://api-gateway/organizationopen/;
  42. }
  43. location ^~ /dl/coupon/api/ {
  44. proxy_pass http://api-gateway/couponopen/;
  45. }
  46. location ^~ /dl/biz/api/ {
  47. proxy_pass http://api-gateway/bizopen/;
  48. }
  49. location ^~ /da/api/auth/ {
  50. proxy_pass http://api-gateway/da/auth/;
  51. }
  52. location ^~ /da/api/ {
  53. proxy_pass http://api-gateway/da/api/;
  54. }
  55. location ^~ /da/api/ws/ {
  56. proxy_set_header Upgrade $http_upgrade;
  57. proxy_set_header Connection "upgrade";
  58. proxy_pass http://127.0.0.1:19000/;
  59. }
  60. location ^~ /sp/api/auth/ {
  61. proxy_pass http://api-gateway/sp/web/auth/;
  62. }
  63. location ^~ /sp/api/ {
  64. proxy_pass http://api-gateway/sp/web/;
  65. }
  66. location ^~ /pp/api/auth/ {
  67. proxy_pass http://api-gateway/pp/web/auth/;
  68. }
  69. location ^~ /pp/api/ {
  70. proxy_pass http://api-gateway/pp/web/;
  71. }
  72. location ^~ /scb/api/auth/ {
  73. proxy_pass http://api-gateway/scb/web/auth/;
  74. }
  75. location ^~ /scb/api/ {
  76. proxy_pass http://api-gateway/scb/web/;
  77. }
  78. location ^~ /wms/api/auth/ {
  79. proxy_pass http://api-gateway/wms/api/auth/;
  80. }
  81. location ^~ /wms/api/ {
  82. proxy_pass http://api-gateway/wms/api/;
  83. }
  84. location ^~ /wms-pda/api/auth/ {
  85. proxy_pass http://api-gateway/wms-pda/api/auth/;
  86. }
  87. location ^~ /wms-pda/api/ {
  88. proxy_pass http://api-gateway/wms-pda/api/;
  89. }
  90. location ^~ /hms/api/auth/ {
  91. proxy_pass http://api-gateway/hms/web/auth/;
  92. }
  93. location ^~ /hms/api/ {
  94. proxy_pass http://api-gateway/hms/web/;
  95. }
  96. location ^~ /ccb/app/api/ {
  97. proxy_pass http://api-gateway/ccb/app/api/;
  98. }
  99. location ^~ /bes/api/auth/ {
  100. proxy_pass http://api-gateway/bes/web/auth/;
  101. }
  102. location ^~ /bes/api/ {
  103. proxy_pass http://api-gateway/bes/web/;
  104. }
  105. location ^~ /sms/api/auth/ {
  106. proxy_pass http://api-gateway/sms/web/auth/;
  107. }
  108. location ^~ /sms/api/ {
  109. proxy_pass http://api-gateway/sms/web/;
  110. }
  111. location ^~ /sg/app/ {
  112. proxy_pass http://api-gateway/sg/app/;
  113. }
  114. location ^~ /sg/app/auth/ {
  115. proxy_pass http://api-gateway/sg/app/auth/;
  116. }
  117. location ^~ /ps/app/auth/ {
  118. proxy_pass http://api-gateway/ps/app/auth/;
  119. }
  120. location ^~ /ps/app/ {
  121. proxy_pass http://api-gateway/ps/app/;
  122. }
  123. location ^~ /mp/api/auth/ {
  124. proxy_pass http://api-gateway/mp/web/auth/;
  125. }
  126. location ^~ /mp/api/ {
  127. proxy_pass http://api-gateway/mp/web/;
  128. }
  129. location / {
  130. alias /usr/fuwushe/html/hms/;
  131. index index.html index.htm;
  132. try_files $uri $uri/ /index.html;
  133. }
  134. }
  135. #server {
  136. #listen 80;
  137. #server_name mp.aiqin.com;
  138. #rewrite ^(.*)$ https://$host$1 permanent;
  139. #}
  140. server {
  141. listen 80;
  142. listen 443 ssl;
  143. server_name mp.aiqin.com;
  144. index index_https.html index.htm;
  145. ssl_certificate /usr/soft/nginx/cert/mp.aiqin.com.pem;
  146. ssl_certificate_key /usr/soft/nginx/cert/mp.aiqin.com.key;
  147. ssl_session_timeout 5m;
  148. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  149. ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
  150. ssl_prefer_server_ciphers on;
  151. location ^~ /api {
  152. add_header Access-Control-Allow-Methods *;
  153. add_header Access-Control-Max-Age 3600;
  154. add_header Access-Control-Allow-Credentials true;
  155. add_header Access-Control-Allow-Origin $http_origin;
  156. add_header Access-Control-Allow-Headers $http_access_control_request_headers;
  157. proxy_buffer_size 512k;
  158. proxy_buffers 16 512k;
  159. proxy_set_header Host $host:$server_port;
  160. proxy_set_header X-Real-IP $remote_addr;
  161. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  162. proxy_set_header X-Forwarded-Proto $scheme;
  163. proxy_read_timeout 3600;
  164. proxy_send_timeout 3600;
  165. proxy_pass http://api-gateway/mp/web/;
  166. }
  167. location / {
  168. expires -1s;
  169. add_header Cache-Control no-cache;
  170. add_header Cache-Control private;
  171. alias /usr/fuwushe/html/mp/;
  172. index index.html index.htm;
  173. }
  174. }
  175. server {
  176. listen 80;
  177. server_name azg.aiqin.com;
  178. #charset koi8-r;
  179. #access_log logs/host.access.log main;
  180. proxy_buffer_size 512k;
  181. proxy_buffers 16 512k;
  182. proxy_set_header Host $host:$server_port;
  183. proxy_set_header X-Real-IP $remote_addr;
  184. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  185. proxy_set_header X-Forwarded-Proto $scheme;
  186. location / {
  187. alias /usr/fuwushe/html/sms/;
  188. index index.html index.htm;
  189. try_files $uri $uri/ /index.html;
  190. }
  191. location ^~ /api/auth/ {
  192. proxy_pass http://api-gateway/dls/web/mall/auth/;
  193. }
  194. location ^~ /api/dls/ {
  195. proxy_pass http://api-gateway/dls/web/mall/;
  196. }
  197. location ^~ /dl/tls/api/ {
  198. proxy_pass http://api-gateway/tlsopen/;
  199. }
  200. location ^~ /dl/tms/api/ {
  201. proxy_pass http://api-gateway/tmsopen/;
  202. }
  203. location ^~ /dl/material/api/ {
  204. proxy_pass http://api-gateway/organizationopen/;
  205. }
  206. location ^~ /dl/coupon/api/ {
  207. proxy_pass http://api-gateway/couponopen/;
  208. }
  209. location ^~ /dl/biz/api/ {
  210. proxy_pass http://api-gateway/bizopen/;
  211. }
  212. location ^~ /da/api/auth/ {
  213. proxy_pass http://api-gateway/da/auth/;
  214. }
  215. location ^~ /da/api/ {
  216. proxy_pass http://api-gateway/da/api/;
  217. }
  218. location ^~ /da/api/ws/ {
  219. proxy_set_header Upgrade $http_upgrade;
  220. proxy_set_header Connection "upgrade";
  221. proxy_pass http://127.0.0.1:19000/;
  222. }
  223. location ^~ /sp/api/auth/ {
  224. proxy_pass http://api-gateway/sp/web/auth/;
  225. }
  226. location ^~ /sp/api/ {
  227. proxy_pass http://api-gateway/sp/web/;
  228. }
  229. location ^~ /pp/api/auth/ {
  230. proxy_pass http://api-gateway/pp/web/auth/;
  231. }
  232. location ^~ /pp/api/ {
  233. proxy_pass http://api-gateway/pp/web/;
  234. }
  235. location ^~ /scb/api/auth/ {
  236. proxy_pass http://api-gateway/scb/web/auth/;
  237. }
  238. location ^~ /scb/api/ {
  239. proxy_pass http://api-gateway/scb/web/;
  240. }
  241. location ^~ /wms/api/auth/ {
  242. proxy_pass http://api-gateway/wms/api/auth/;
  243. }
  244. location ^~ /wms/api/ {
  245. proxy_pass http://api-gateway/wms/api/;
  246. }
  247. location ^~ /wms-pda/api/auth/ {
  248. proxy_pass http://api-gateway/wms-pda/api/auth/;
  249. }
  250. location ^~ /wms-pda/api/ {
  251. proxy_pass http://api-gateway/wms-pda/api/;
  252. }
  253. location ^~ /hms/api/auth/ {
  254. proxy_pass http://api-gateway/hms/web/auth/;
  255. }
  256. location ^~ /hms/api/ {
  257. proxy_pass http://api-gateway/hms/web/;
  258. }
  259. location ^~ /ccb/app/api/ {
  260. proxy_pass http://api-gateway/ccb/app/api/;
  261. }
  262. location ^~ /bes/api/auth/ {
  263. proxy_pass http://api-gateway/bes/web/auth/;
  264. }
  265. location ^~ /bes/api/ {
  266. proxy_pass http://api-gateway/bes/web/;
  267. }
  268. location ^~ /sms/api/auth/ {
  269. proxy_pass http://api-gateway/sms/web/auth/;
  270. }
  271. location ^~ /sms/api/ {
  272. proxy_pass http://api-gateway/sms/web/;
  273. }
  274. location ^~ /sg/app/ {
  275. proxy_pass http://api-gateway/sg/app/;
  276. }
  277. location ^~ /sg/app/auth/ {
  278. proxy_pass http://api-gateway/sg/app/auth/;
  279. }
  280. location ^~ /ps/app/auth/ {
  281. proxy_pass http://api-gateway/ps/app/auth/;
  282. }
  283. location ^~ /ps/app/ {
  284. proxy_pass http://api-gateway/ps/app/;
  285. }
  286. location ^~ /mp/api/auth/ {
  287. proxy_pass http://api-gateway/mp/web/auth/;
  288. }
  289. location ^~ /mp/api/ {
  290. proxy_pass http://api-gateway/mp/web/;
  291. }
  292. #error_page 404 /404.html;
  293. # redirect server error pages to the static page /50x.html
  294. #
  295. error_page 500 502 503 504 /50x.html;
  296. location = /50x.html {
  297. root html;
  298. }
  299. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  300. #
  301. #location ~ \.php$ {
  302. # proxy_pass http://127.0.0.1;
  303. #}
  304. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  305. #
  306. #location ~ \.php$ {
  307. # root html;
  308. # fastcgi_pass 127.0.0.1:9000;
  309. # fastcgi_index index.php;
  310. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  311. # include fastcgi_params;
  312. #}
  313. # deny access to .htaccess files, if Apache's document root
  314. # concurs with nginx's one
  315. #
  316. #location ~ /\.ht {
  317. # deny all;
  318. #}
  319. }
  320. # another virtual host using mix of IP-, name-, and port-based configuration
  321. #
  322. #server {
  323. # listen 8000;
  324. # listen somename:8080;
  325. # server_name somename alias another.alias;
  326. # location / {
  327. # root html;
  328. # index index.html index.htm;
  329. # }
  330. #}
  331. # HTTPS server
  332. #
  333. #server {
  334. # listen 443 ssl;
  335. # server_name localhost;
  336. # ssl_certificate cert.pem;
  337. # ssl_certificate_key cert.key;
  338. # ssl_session_cache shared:SSL:1m;
  339. # ssl_session_timeout 5m;
  340. # ssl_ciphers HIGH:!aNULL:!MD5;
  341. # ssl_prefer_server_ciphers on;
  342. # location / {
  343. # root html;
  344. # index index.html index.htm;
  345. # }
  346. #}

}

  1. ---
  2. 带端口的配置:
  3. ```json
  4. user root;
  5. worker_processes 1;
  6. #error_log logs/error.log;
  7. #error_log logs/error.log notice;
  8. #error_log logs/error.log info;
  9. #pid logs/nginx.pid;
  10. events {
  11. worker_connections 1024;
  12. }
  13. http {
  14. client_max_body_size 10m;
  15. include mime.types;
  16. default_type application/octet-stream;
  17. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  18. # '$status $body_bytes_sent "$http_referer" '
  19. # '"$http_user_agent" "$http_x_forwarded_for"';
  20. #access_log logs/access.log main;
  21. sendfile on;
  22. #tcp_nopush on;
  23. #keepalive_timeout 0;
  24. keepalive_timeout 65;
  25. # 开启gzip
  26. gzip on;
  27. # 启用gzip压缩的最小文件;小于设置值的文件将不会被压缩
  28. gzip_min_length 1k;
  29. # gzip 压缩级别 1-10
  30. gzip_comp_level 2;
  31. # 进行压缩的文件类型。
  32. gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
  33. # 是否在http header中添加Vary: Accept-Encoding,建议开启
  34. gzip_vary on;
  35. add_header Cache-Control private;
  36. server {
  37. listen 18889;
  38. server_name dev.codepush.daruiyun.com;
  39. location ^~ / {
  40. proxy_pass http://127.0.0.1:3000/;
  41. }
  42. }
  43. server {
  44. listen 18889;
  45. server_name dev.api.daruiyun.com;
  46. #charset koi8-r;
  47. #access_log logs/host.access.log main;
  48. location / {
  49. alias /usr/fuwushe/font/;
  50. index index.html index.htm;
  51. try_files $uri $uri/ /index.html;
  52. }
  53. location /da/ {
  54. alias /usr/fuwushe/font/da/;
  55. index index.html index.htm;
  56. try_files $uri $uri/ /index.html;
  57. }
  58. location /zxlmp/img/ {
  59. alias /use/zxlmp/img/;
  60. index index.html index.htm;
  61. try_files $uri $uri/ /index.html;
  62. }
  63. location ^~ /api/auth/ {
  64. proxy_pass http://127.0.0.1:13000/dls/web/mall/auth/;
  65. }
  66. location ^~ /api/dls/ {
  67. proxy_pass http://127.0.0.1:13000/dls/web/mall/;
  68. }
  69. location ^~ /dl/tls/api/ {
  70. proxy_pass http://127.0.0.1:13000/tlsopen/;
  71. }
  72. location ^~ /dl/tms/api/ {
  73. proxy_pass http://127.0.0.1:13000/tmsopen/;
  74. }
  75. location ^~ /dl/material/api/ {
  76. proxy_pass http://127.0.0.1:13000/organizationopen/;
  77. }
  78. location ^~ /dl/coupon/api/ {
  79. proxy_pass http://127.0.0.1:13000/couponopen/;
  80. }
  81. location ^~ /dl/biz/api/ {
  82. proxy_pass http://127.0.0.1:13000/bizopen/;
  83. }
  84. location ^~ /da/api/auth/ {
  85. proxy_pass http://127.0.0.1:13000/da/auth/;
  86. }
  87. location ^~ /da/api/ {
  88. proxy_pass http://127.0.0.1:13000/da/api/;
  89. }
  90. location ^~ /da/api/ws/ {
  91. proxy_set_header Upgrade $http_upgrade;
  92. proxy_set_header Connection "upgrade";
  93. proxy_pass http://127.0.0.1:19000/;
  94. }
  95. location ^~ /sp/api/auth/ {
  96. proxy_pass http://127.0.0.1:13000/sp/web/auth/;
  97. }
  98. location ^~ /sp/api/ {
  99. proxy_pass http://127.0.0.1:13000/sp/web/;
  100. }
  101. location ^~ /pp/api/auth/ {
  102. proxy_pass http://127.0.0.1:13000/pp/web/auth/;
  103. }
  104. location ^~ /pp/api/ {
  105. proxy_pass http://127.0.0.1:13000/pp/web/;
  106. }
  107. location ^~ /scb/api/auth/ {
  108. proxy_pass http://127.0.0.1:13000/scb/web/auth/;
  109. }
  110. location ^~ /scb/api/ {
  111. proxy_pass http://127.0.0.1:13000/scb/web/;
  112. }
  113. location ^~ /wms/api/auth/ {
  114. proxy_pass http://127.0.0.1:13000/wms/api/auth/;
  115. }
  116. location ^~ /wms/api/ {
  117. proxy_pass http://127.0.0.1:13000/wms/api/;
  118. }
  119. location ^~ /hms/api/auth/ {
  120. proxy_pass http://127.0.0.1:13000/hms/web/auth/;
  121. }
  122. location ^~ /hms/api/ {
  123. proxy_pass http://127.0.0.1:13000/hms/web/;
  124. }
  125. location ^~ /ccb/app/api/ {
  126. proxy_pass http://127.0.0.1:13000/ccb/app/api/;
  127. }
  128. location ^~ /bes/api/auth/ {
  129. proxy_pass http://127.0.0.1:13000/bes/web/auth/;
  130. }
  131. location ^~ /bes/api/ {
  132. proxy_pass http://127.0.0.1:13000/bes/web/;
  133. }
  134. location ^~ /zxlmp/api/ {
  135. proxy_pass http://127.0.0.1:13000/zxlmp/web/;
  136. }
  137. location ^~ /fcb/app/api/ {
  138. proxy_pass http://127.0.0.1:13000/fcb/app/api/;
  139. }
  140. error_page 500 502 503 504 /50x.html;
  141. location = /50x.html {
  142. root html;
  143. }
  144. }
  145. server {
  146. listen 80;
  147. server_name dev.api.daruiyun.com;
  148. location / {
  149. root /usr/soft/env/front/flows-app/;
  150. try_files $uri $uri/ /dl/material/index.html;
  151. }
  152. error_page 500 502 503 504 /50x.html;
  153. location = /50x.html {
  154. root html;
  155. }
  156. }
  157. server {
  158. listen 80;
  159. server_name test.seller.aiqinyouxuan.com;
  160. location / {
  161. root /usr/soft/env/front/icp_admin/;
  162. try_files $uri $uri/ /icp_admin/index.html;
  163. expires -1s;
  164. add_header Cache-Control no-cache;
  165. }
  166. location ^~ /icp/api/auth/ {
  167. proxy_pass http://127.0.0.1:13000/icp/web/auth/;
  168. }
  169. location ^~ /icp/api/ {
  170. proxy_pass http://127.0.0.1:13000/icp/web/;
  171. }
  172. }
  173. server {
  174. listen 6006;
  175. server_name dev.api.daruiyun.com;
  176. location / {
  177. root /usr/soft/env/front/fm/;
  178. try_files $uri $uri/ /fm/index.html;
  179. expires -1s;
  180. add_header Cache-Control no-cache;
  181. }
  182. error_page 500 502 503 504 /50x.html;
  183. location = /50x.html {
  184. root html;
  185. }
  186. }
  187. server {
  188. listen 6007;
  189. server_name dev.api.daruiyun.com;
  190. location / {
  191. root /usr/soft/env/front/pos-desktop/;
  192. try_files $uri $uri/ /index.html;
  193. expires -1s;
  194. add_header Cache-Control no-cache;
  195. }
  196. error_page 500 502 503 504 /50x.html;
  197. location = /50x.html {
  198. root html;
  199. }
  200. }
  201. server {
  202. listen 6009;
  203. server_name dev.api.daruiyun.com;
  204. location / {
  205. root /usr/soft/env/front/little_red_horse_admin/;
  206. try_files $uri $uri/ /dl/material/index.html;
  207. expires -1s;
  208. add_header Cache-Control no-cache;
  209. }
  210. error_page 500 502 503 504 /50x.html;
  211. location = /50x.html {
  212. root html;
  213. }
  214. }
  215. server {
  216. listen 6010;
  217. server_name dev.api.daruiyun.com;
  218. location / {
  219. root /usr/soft/env/front/aq_shop/;
  220. try_files $uri $uri/ /aq_shop/index.html;
  221. expires -1s;
  222. add_header Cache-Control no-cache;
  223. }
  224. error_page 500 502 503 504 /50x.html;
  225. location = /50x.html {
  226. root html;
  227. }
  228. }
  229. server {
  230. listen 6011;
  231. server_name dev.api.daruiyun.com;
  232. location / {
  233. root /usr/soft/env/front/sms/;
  234. try_files $uri $uri/ /index.html;
  235. expires -1s;
  236. add_header Cache-Control no-cache;
  237. }
  238. error_page 500 502 503 504 /50x.html;
  239. location = /50x.html {
  240. root html;
  241. }
  242. }
  243. server {
  244. listen 6010;
  245. server_name dev.api.daruiyun.com;
  246. location / {
  247. root /usr/soft/env/front/aq_shop/;
  248. try_files $uri $uri/ /aq_shop/index.html;
  249. expires -1s;
  250. add_header Cache-Control no-cache;
  251. }
  252. error_page 500 502 503 504 /50x.html;
  253. location = /50x.html {
  254. root html;
  255. }
  256. }
  257. server {
  258. listen 443 ssl;
  259. server_name test.aqsg.daruiyun.com;
  260. root html;
  261. index index_https.html index.htm;
  262. ssl on;
  263. ssl_certificate /usr/local/nginx/cert/5827163_test.aqsg.daruiyun.com.pem;
  264. ssl_certificate_key /usr/local/nginx/cert/5827163_test.aqsg.daruiyun.com.key;
  265. ssl_session_timeout 5m;
  266. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  267. ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
  268. ssl_prefer_server_ciphers on;
  269. location /aqsg {
  270. alias /usr/fuwushe/font/aqsg;
  271. index index.html index.htm;
  272. }
  273. location / {
  274. proxy_pass http://127.0.0.1:13000/;
  275. add_header Access-Control-Allow-Methods *;
  276. add_header Access-Control-Max-Age 3600;
  277. add_header Access-Control-Allow-Credentials true;
  278. add_header Access-Control-Allow-Origin $http_origin;
  279. add_header Access-Control-Allow-Headers $http_access_control_request_headers;
  280. if ($request_method = OPTIONS){
  281. return 200;
  282. }
  283. }
  284. }
  285. server {
  286. listen 443 ssl;
  287. server_name test.mengbeishu.daruiyun.com;
  288. root html;
  289. index index_https.html index.htm;
  290. ssl on;
  291. ssl_certificate /usr/local/nginx/cert/2632587_test.mengbeishu.daruiyun.com.pem;
  292. ssl_certificate_key /usr/local/nginx/cert/2632587_test.mengbeishu.daruiyun.com.key;
  293. ssl_session_timeout 5m;
  294. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  295. ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
  296. ssl_prefer_server_ciphers on;
  297. location /mbs {
  298. alias /usr/fuwushe/font/mbs;
  299. index index.html index.htm;
  300. }
  301. location /YNL5De3iYY.txt {
  302. alias /usr/fuwushe/font/mbs;
  303. index YNL5De3iYY.txt;
  304. }
  305. location / {
  306. proxy_pass http://127.0.0.1:13000/;
  307. add_header Access-Control-Allow-Methods *;
  308. add_header Access-Control-Max-Age 3600;
  309. add_header Access-Control-Allow-Credentials true;
  310. add_header Access-Control-Allow-Origin $http_origin;
  311. add_header Access-Control-Allow-Headers $http_access_control_request_headers;
  312. if ($request_method = OPTIONS){
  313. return 200;
  314. }
  315. }
  316. }
  317. }

配置完成后重新启动服务器:

  1. cd /usr/soft/nginx/sbin
  2. ./nginx -s reload

以上是一些 nginx 的基本配置~