nginx.conf 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. worker_processes auto; # 自动根据CPU核心数设置
  2. events {
  3. worker_connections 1024;
  4. multi_accept on;
  5. use epoll;
  6. }
  7. http {
  8. include /etc/nginx/mime.types;
  9. default_type application/octet-stream;
  10. # 基础优化配置
  11. sendfile on;
  12. tcp_nopush on;
  13. tcp_nodelay on;
  14. keepalive_timeout 65;
  15. types_hash_max_size 2048;
  16. server_tokens off; # 隐藏版本号
  17. # 性能优化配置
  18. client_max_body_size 20m;
  19. client_body_buffer_size 128k;
  20. proxy_buffer_size 4k;
  21. proxy_buffers 4 32k;
  22. proxy_busy_buffers_size 64k;
  23. # 全局 gzip 配置
  24. gzip on;
  25. gzip_vary on;
  26. gzip_min_length 10240;
  27. gzip_proxied expired no-cache no-store private auth;
  28. gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript;
  29. gzip_disable "MSIE [1-6]\.";
  30. # 日志配置优化
  31. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  32. '$status $body_bytes_sent "$http_referer" '
  33. '"$http_user_agent" "$http_x_forwarded_for"';
  34. access_log /var/log/nginx/access.log main buffer=512k flush=1m;
  35. error_log /var/log/nginx/error.log warn;
  36. # 允许跨域访问
  37. map $http_origin $cors_origin {
  38. default "";
  39. "~^https?://[^/]+\.hht\.test(:[0-9]+)?$" "$http_origin";
  40. "~^https?://localhost(:[0-9]+)?$" "$http_origin";
  41. }
  42. # 通用安全头部配置
  43. map $http_upgrade $connection_upgrade {
  44. default upgrade;
  45. '' close;
  46. }
  47. # 通用配置块
  48. include /etc/nginx/conf.d/*.conf;
  49. # 通用安全头部
  50. add_header X-Frame-Options "SAMEORIGIN" always;
  51. add_header X-XSS-Protection "1; mode=block" always;
  52. add_header X-Content-Type-Options "nosniff" always;
  53. add_header Referrer-Policy "no-referrer-when-downgrade" always;
  54. add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
  55. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  56. add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
  57. # 错误页面配置
  58. error_page 404 /404.html;
  59. error_page 500 502 503 504 /50x.html;
  60. # Element2 子域名配置
  61. server {
  62. listen 80;
  63. server_name element2.hht.test;
  64. access_log /var/log/nginx/element2.access.log main;
  65. error_log /var/log/nginx/element2.error.log warn;
  66. location / {
  67. root /usr/share/nginx/html/element2;
  68. index index.html index.htm;
  69. try_files $uri $uri/ /index.html;
  70. # 针对不同类型的文件设置不同的缓存时间
  71. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  72. expires 7d;
  73. add_header Cache-Control "public, no-transform";
  74. }
  75. location ~* \.(html|htm)$ {
  76. expires 1h;
  77. add_header Cache-Control "public, no-transform";
  78. }
  79. # 跨域支持
  80. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  81. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  82. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  83. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  84. }
  85. }
  86. # Element3 子域名配置
  87. server {
  88. listen 80;
  89. server_name element3.hht.test;
  90. access_log /var/log/nginx/element3.access.log main;
  91. error_log /var/log/nginx/element3.error.log warn;
  92. location / {
  93. root /usr/share/nginx/html/element-plus;
  94. index index.html index.htm;
  95. try_files $uri $uri/ /index.html;
  96. # 针对不同类型的文件设置不同的缓存时间
  97. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  98. expires 7d;
  99. add_header Cache-Control "public, no-transform";
  100. }
  101. location ~* \.(html|htm)$ {
  102. expires 1h;
  103. add_header Cache-Control "public, no-transform";
  104. }
  105. # 跨域支持
  106. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  107. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  108. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  109. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  110. }
  111. }
  112. # Vue2 子域名配置
  113. server {
  114. listen 80;
  115. server_name vue2.hht.test;
  116. access_log /var/log/nginx/vue2.access.log main;
  117. error_log /var/log/nginx/vue2.error.log warn;
  118. location / {
  119. alias /usr/share/nginx/html/v2.cn.vuejs.org/;
  120. index index.html index.htm;
  121. try_files $uri $uri/ /index.html;
  122. # 针对不同类型的文件设置不同的缓存时间
  123. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  124. expires 7d;
  125. add_header Cache-Control "public, no-transform";
  126. }
  127. location ~* \.(html|htm)$ {
  128. expires 1h;
  129. add_header Cache-Control "public, no-transform";
  130. }
  131. # 跨域支持
  132. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  133. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  134. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  135. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  136. }
  137. }
  138. # Vant 子域名配置
  139. server {
  140. listen 80;
  141. server_name vant.hht.test;
  142. access_log /var/log/nginx/vant.access.log main;
  143. error_log /var/log/nginx/vant.error.log warn;
  144. location / {
  145. alias /usr/share/nginx/html/vant/;
  146. index index.html index.htm;
  147. try_files $uri $uri/ /index.html;
  148. # 针对不同类型的文件设置不同的缓存时间
  149. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  150. expires 7d;
  151. add_header Cache-Control "public, no-transform";
  152. }
  153. location ~* \.(html|htm)$ {
  154. expires 1h;
  155. add_header Cache-Control "public, no-transform";
  156. }
  157. # 跨域支持
  158. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  159. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  160. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  161. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  162. }
  163. location /vant/ {
  164. alias /usr/share/nginx/html/vant/;
  165. try_files $uri $uri/ /tparking/index.html;
  166. index index.html;
  167. # 跨域支持
  168. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  169. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  170. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  171. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  172. }
  173. }
  174. # Vue3 子域名配置
  175. server {
  176. listen 80;
  177. listen 8877; # 添加 8877 端口监听
  178. server_name vue3.hht.test;
  179. # 日志配置
  180. access_log /var/log/nginx/vue3.access.log main buffer=32k flush=5s;
  181. error_log /var/log/nginx/vue3.error.log warn;
  182. # 安全相关配置
  183. add_header X-Frame-Options "SAMEORIGIN" always;
  184. add_header X-XSS-Protection "1; mode=block" always;
  185. add_header X-Content-Type-Options "nosniff" always;
  186. # 性能优化
  187. client_max_body_size 10m;
  188. client_body_timeout 12;
  189. client_header_timeout 12;
  190. keepalive_timeout 15;
  191. send_timeout 10;
  192. # 字体文件 MIME 类型
  193. include /etc/nginx/mime.types;
  194. types {
  195. font/woff2 woff2;
  196. font/woff woff;
  197. font/ttf ttf;
  198. font/eot eot;
  199. }
  200. location / {
  201. alias /usr/share/nginx/html/docs-zh-cn/.vitepress/dist/;
  202. index index.html index.htm;
  203. try_files $uri $uri/ /index.html;
  204. # 针对不同类型的文件设置不同的缓存时间
  205. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  206. expires 7d;
  207. add_header Cache-Control "public, no-transform";
  208. access_log off;
  209. }
  210. location ~* \.(html|htm)$ {
  211. expires 1h;
  212. add_header Cache-Control "public, no-transform";
  213. }
  214. # 禁止访问隐藏文件
  215. location ~ /\. {
  216. deny all;
  217. access_log off;
  218. log_not_found off;
  219. }
  220. # 禁止访问 .git 目录
  221. location ~ /\.git {
  222. deny all;
  223. access_log off;
  224. log_not_found off;
  225. }
  226. }
  227. # 静态资源缓存优化
  228. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
  229. root /usr/share/nginx/html/docs-zh-cn/.vitepress/dist;
  230. expires 7d;
  231. add_header Cache-Control "public, no-transform";
  232. access_log off;
  233. tcp_nodelay off;
  234. open_file_cache max=1000 inactive=20s;
  235. open_file_cache_valid 30s;
  236. open_file_cache_min_uses 2;
  237. open_file_cache_errors on;
  238. try_files $uri =404;
  239. }
  240. # 错误页面配置
  241. error_page 404 /404.html;
  242. error_page 500 502 503 504 /50x.html;
  243. location = /404.html {
  244. internal;
  245. }
  246. location = /50x.html {
  247. internal;
  248. }
  249. }
  250. # 2x ant-design 子域名配置
  251. server {
  252. listen 80;
  253. server_name 2x-ant-design.hht.test;
  254. access_log /var/log/nginx/2x-ant-design.access.log main;
  255. error_log /var/log/nginx/2x-ant-design.error.log warn;
  256. location / {
  257. root /usr/share/nginx/html/2x.ant.design;
  258. index index.html index.htm;
  259. try_files $uri $uri/ @router;
  260. # 针对不同类型的文件设置不同的缓存时间
  261. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  262. expires 7d;
  263. add_header Cache-Control "public, no-transform";
  264. }
  265. location ~* \.(html|htm)$ {
  266. expires 1h;
  267. add_header Cache-Control "public, no-transform";
  268. }
  269. # 跨域支持
  270. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  271. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  272. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  273. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  274. }
  275. location @router {
  276. rewrite ^.*$ /index.html last;
  277. }
  278. }
  279. # 2x antv-design 子域名配置
  280. server {
  281. listen 80;
  282. server_name 2x-antv-design.hht.test;
  283. access_log /var/log/nginx/2x-antv-design.access.log main;
  284. error_log /var/log/nginx/2x-antv-design.error.log warn;
  285. location / {
  286. root /usr/share/nginx/html/2x.antv.design;
  287. index index.html index.htm;
  288. try_files $uri $uri/ @router;
  289. # 针对不同类型的文件设置不同的缓存时间
  290. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  291. expires 7d;
  292. add_header Cache-Control "public, no-transform";
  293. }
  294. location ~* \.(html|htm)$ {
  295. expires 1h;
  296. add_header Cache-Control "public, no-transform";
  297. }
  298. # 跨域支持
  299. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  300. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  301. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  302. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  303. }
  304. location @router {
  305. rewrite ^.*$ /index.html last;
  306. }
  307. }
  308. # 3x ant-design 子域名配置
  309. server {
  310. listen 80;
  311. server_name 3x-ant-design.hht.test;
  312. access_log /var/log/nginx/3x-ant-design.access.log main;
  313. error_log /var/log/nginx/3x-ant-design.error.log warn;
  314. location / {
  315. root /usr/share/nginx/html/3x.ant.design;
  316. index index.html index.htm;
  317. try_files $uri $uri/ @router;
  318. # 针对不同类型的文件设置不同的缓存时间
  319. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  320. expires 7d;
  321. add_header Cache-Control "public, no-transform";
  322. }
  323. location ~* \.(html|htm)$ {
  324. expires 1h;
  325. add_header Cache-Control "public, no-transform";
  326. }
  327. # 跨域支持
  328. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  329. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  330. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  331. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  332. }
  333. location @router {
  334. rewrite ^.*$ /index.html last;
  335. }
  336. }
  337. # 3x antv-design 子域名配置
  338. server {
  339. listen 80;
  340. server_name 3x-antv-design.hht.test;
  341. access_log /var/log/nginx/3x-antv-design.access.log main;
  342. error_log /var/log/nginx/3x-antv-design.error.log warn;
  343. location / {
  344. root /usr/share/nginx/html/3x.antv.design;
  345. index index.html index.htm;
  346. try_files $uri $uri/ @router;
  347. # 针对不同类型的文件设置不同的缓存时间
  348. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  349. expires 7d;
  350. add_header Cache-Control "public, no-transform";
  351. }
  352. location ~* \.(html|htm)$ {
  353. expires 1h;
  354. add_header Cache-Control "public, no-transform";
  355. }
  356. # 跨域支持
  357. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  358. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  359. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  360. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  361. }
  362. location @router {
  363. rewrite ^.*$ /index.html last;
  364. }
  365. }
  366. # 4x ant-design 子域名配置
  367. server {
  368. listen 80;
  369. server_name 4x-ant-design.hht.test;
  370. # 日志配置
  371. access_log /var/log/nginx/4x-ant-design.access.log main buffer=32k flush=5s;
  372. error_log /var/log/nginx/4x-ant-design.error.log warn;
  373. # 安全相关配置
  374. add_header X-Frame-Options "SAMEORIGIN" always;
  375. add_header X-XSS-Protection "1; mode=block" always;
  376. add_header X-Content-Type-Options "nosniff" always;
  377. # 性能优化
  378. client_max_body_size 10m;
  379. client_body_timeout 12;
  380. client_header_timeout 12;
  381. keepalive_timeout 15;
  382. send_timeout 10;
  383. # 字体文件 MIME 类型
  384. include /etc/nginx/mime.types;
  385. types {
  386. font/woff2 woff2;
  387. font/woff woff;
  388. font/ttf ttf;
  389. font/eot eot;
  390. }
  391. location / {
  392. root /usr/share/nginx/html/4x.ant.design;
  393. index index.html index.htm;
  394. try_files $uri $uri/ @router;
  395. # 针对不同类型的文件设置不同的缓存时间
  396. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  397. expires 7d;
  398. add_header Cache-Control "public, no-transform";
  399. access_log off;
  400. }
  401. location ~* \.(html|htm)$ {
  402. expires 1h;
  403. add_header Cache-Control "public, no-transform";
  404. }
  405. # 禁止访问隐藏文件
  406. location ~ /\. {
  407. deny all;
  408. access_log off;
  409. log_not_found off;
  410. }
  411. # 禁止访问 .git 目录
  412. location ~ /\.git {
  413. deny all;
  414. access_log off;
  415. log_not_found off;
  416. }
  417. # 跨域支持
  418. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  419. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  420. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  421. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  422. }
  423. # 静态资源缓存优化
  424. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
  425. root /usr/share/nginx/html/4x-ant-design;
  426. expires 7d;
  427. add_header Cache-Control "public, no-transform";
  428. access_log off;
  429. tcp_nodelay off;
  430. open_file_cache max=1000 inactive=20s;
  431. open_file_cache_valid 30s;
  432. open_file_cache_min_uses 2;
  433. open_file_cache_errors on;
  434. try_files $uri =404;
  435. }
  436. location @router {
  437. rewrite ^.*$ /index.html last;
  438. }
  439. # 错误页面配置
  440. error_page 404 /404.html;
  441. error_page 500 502 503 504 /50x.html;
  442. location = /404.html {
  443. internal;
  444. }
  445. location = /50x.html {
  446. internal;
  447. }
  448. }
  449. # ant-design 子域名配置
  450. server {
  451. listen 80;
  452. server_name ant-design.hht.test;
  453. access_log /var/log/nginx/ant-design.access.log main;
  454. error_log /var/log/nginx/ant-design.error.log warn;
  455. location / {
  456. root /usr/share/nginx/html/ant-design;
  457. index index.html index.htm;
  458. try_files $uri $uri/ @router;
  459. # 针对不同类型的文件设置不同的缓存时间
  460. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  461. expires 7d;
  462. add_header Cache-Control "public, no-transform";
  463. }
  464. location ~* \.(html|htm)$ {
  465. expires 1h;
  466. add_header Cache-Control "public, no-transform";
  467. }
  468. # 跨域支持
  469. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  470. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  471. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  472. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  473. }
  474. location @router {
  475. rewrite ^.*$ /index.html last;
  476. }
  477. }
  478. # 1x-ant-design-vue 子域名配置
  479. server {
  480. listen 80;
  481. server_name 1x-antv-design.hht.test;
  482. access_log /var/log/nginx/1x-antv-design.access.log main;
  483. error_log /var/log/nginx/1x-antv-design.error.log warn;
  484. location / {
  485. root /usr/share/nginx/html/1x.antv.design;
  486. index index.html index.htm;
  487. try_files $uri $uri/ @router;
  488. # 针对不同类型的文件设置不同的缓存时间
  489. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  490. expires 7d;
  491. add_header Cache-Control "public, no-transform";
  492. }
  493. location ~* \.(html|htm)$ {
  494. expires 1h;
  495. add_header Cache-Control "public, no-transform";
  496. }
  497. # 跨域支持
  498. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  499. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  500. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  501. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  502. }
  503. location @router {
  504. rewrite ^.*$ /index.html last;
  505. }
  506. }
  507. # ant-design-vue 子域名配置
  508. server {
  509. listen 80;
  510. server_name ant-design-vue.hht.test;
  511. access_log /var/log/nginx/antv-design.access.log main;
  512. error_log /var/log/nginx/antv-design.error.log warn;
  513. location / {
  514. root /usr/share/nginx/html/ant-design-vue/site/dist/;
  515. index index.html index.htm;
  516. try_files $uri $uri/ @router;
  517. # 针对不同类型的文件设置不同的缓存时间
  518. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  519. expires 7d;
  520. add_header Cache-Control "public, no-transform";
  521. }
  522. location ~* \.(html|htm)$ {
  523. expires 1h;
  524. add_header Cache-Control "public, no-transform";
  525. }
  526. # 跨域支持
  527. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  528. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  529. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  530. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  531. }
  532. location @router {
  533. rewrite ^.*$ /index.html last;
  534. }
  535. }
  536. # better-scroll 子域名配置
  537. server {
  538. listen 80;
  539. server_name better-scroll-docs.hht.test;
  540. location / {
  541. #root /Users/sysadmin/code/vue_project/better-scroll-docs/zh-CN;
  542. #index index.html index.htm;
  543. alias /usr/share/nginx/html/better-scroll-docs/zh-CN/;
  544. try_files $uri $uri/ /index.html;
  545. index index.html;
  546. add_header Access-Control-Allow-Origin *;
  547. }
  548. location /docs/ {
  549. alias /usr/share/nginx/html/better-scroll-docs/;
  550. #try_files $uri $uri/ /tparking/index.html;
  551. #index index.html;
  552. #add_header Access-Control-Allow-Origin *;
  553. }
  554. }
  555. # tauri-docs 子域名配置
  556. server {
  557. listen 80;
  558. server_name tauri-docs.hht.test;
  559. location / {
  560. #root /Users/sysadmin/code/vue_project/better-scroll-docs/zh-CN;
  561. #index index.html index.htm;
  562. alias /usr/share/nginx/html/tauri-docs/dist/;
  563. try_files $uri $uri/ /index.html;
  564. index index.html;
  565. add_header Access-Control-Allow-Origin *;
  566. }
  567. }
  568. # 1x-tauri-docs 子域名配置
  569. server {
  570. listen 80;
  571. server_name 1x-tauri-docs.hht.test;
  572. location / {
  573. #root /Users/sysadmin/code/vue_project/better-scroll-docs/zh-CN;
  574. #index index.html index.htm;
  575. alias /usr/share/nginx/html/tauri-docs-v1/build/;
  576. try_files $uri $uri/ /index.html;
  577. index index.html;
  578. add_header Access-Control-Allow-Origin *;
  579. }
  580. }
  581. # electron-website 子域名配置
  582. server {
  583. listen 80;
  584. server_name electron-website.hht.test;
  585. location / {
  586. #root /Users/sysadmin/code/vue_project/better-scroll-docs/zh-CN;
  587. #index index.html index.htm;
  588. alias /usr/share/nginx/html/electron-website/build/;
  589. try_files $uri $uri/ /index.html;
  590. index index.html;
  591. add_header Access-Control-Allow-Origin *;
  592. }
  593. location /zh/ {
  594. alias /usr/share/nginx/html/electron-website/build/;
  595. try_files $uri $uri/ /index.html;
  596. index index.html;
  597. # 跨域支持
  598. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  599. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  600. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  601. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  602. }
  603. location /docs/ {
  604. alias /usr/share/nginx/html/electron-website/build/;
  605. try_files $uri $uri/ /index.html;
  606. index index.html;
  607. # 跨域支持
  608. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  609. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  610. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  611. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  612. }
  613. location /apps/ {
  614. alias /usr/share/nginx/html/electron-website/build/;
  615. try_files $uri $uri/ /index.html;
  616. index index.html;
  617. # 跨域支持
  618. add_header 'Access-Control-Allow-Origin' $cors_origin always;
  619. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  620. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  621. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
  622. }
  623. }
  624. # 默认服务器配置
  625. server {
  626. listen 80 default_server;
  627. server_name _;
  628. return 404;
  629. }
  630. }