cloudpure.conf 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Canonical host and HTTPS redirects. Replace certificate paths before applying.
  2. server {
  3. listen 80;
  4. server_name cloudpure.cn www.cloudpure.cn;
  5. return 301 https://www.cloudpure.cn$request_uri;
  6. }
  7. server {
  8. listen 443 ssl http2;
  9. server_name cloudpure.cn;
  10. ssl_certificate /etc/nginx/certs/cloudpure.cn.pem;
  11. ssl_certificate_key /etc/nginx/certs/cloudpure.cn.key;
  12. return 301 https://www.cloudpure.cn$request_uri;
  13. }
  14. server {
  15. listen 443 ssl http2;
  16. server_name www.cloudpure.cn;
  17. root /opt/web/dist;
  18. index index.html;
  19. ssl_certificate /etc/nginx/certs/cloudpure.cn.pem;
  20. ssl_certificate_key /etc/nginx/certs/cloudpure.cn.key;
  21. location = / {
  22. try_files /home/index.html =404;
  23. }
  24. location ~ ^/(home|product/(version-selection|intelligent-hr|intelligent-recruitment|intelligent-attendance|dingtalk-payroll|dingtalk-yida|teambition|intelligent-finance|intelligent-contract|intelligent-marketing)|ai|fde|digital-base|organization-digital|business-digital|solutions|cases|super-service|about|contact|privacy-policy|news)$ {
  25. return 301 $uri/$is_args$args;
  26. }
  27. # Serve the pre-rendered public pages, preserving their static 200 responses.
  28. location ~ ^/(home|product/(version-selection|intelligent-hr|intelligent-recruitment|intelligent-attendance|dingtalk-payroll|dingtalk-yida|teambition|intelligent-finance|intelligent-contract|intelligent-marketing)|ai|fde|digital-base|organization-digital|business-digital|solutions|cases|super-service|about|contact|privacy-policy|news)/?$ {
  29. try_files $uri $uri/ /$1/index.html =404;
  30. }
  31. location = /order-tai { return 301 /ai/; }
  32. location = /order-tai/ { return 301 /ai/; }
  33. # Keep pre-rendered article HTML when it exists. Fall back to the SPA so
  34. # newly published articles can load by slug before the next prerender.
  35. location = /news/test { return 404; }
  36. location = /news/test/ { return 404; }
  37. location ~ ^/news/article-fe2a72(?:[^/]*)?$ { return 404; }
  38. location ~ ^/news/article-fe2a72(?:[^/]*)?/$ { return 404; }
  39. location ~ ^/news/[^/]+$ { return 301 $uri/$is_args$args; }
  40. location ~ ^/news/[^/]+/$ { try_files $uri $uri/ /index.html; }
  41. location = /robots.txt { try_files $uri =404; }
  42. location = /sitemap.xml { try_files $uri =404; }
  43. location /static/ { try_files $uri =404; expires 30d; }
  44. # Normalize all other public page URLs without a trailing slash. API,
  45. # admin, assets, uploads, and file-like URLs are intentionally excluded.
  46. location ~ ^/(?!prod-api(?:/|$)|admin(?:/|$)|static(?:/|$)|profile(?:/|$)|yunpubullet(?:/|$)|robots\.txt$|sitemap\.xml$)(?:[^/]+/)*[^/.]+$ {
  47. return 301 $uri/$is_args$args;
  48. }
  49. # Do not return the SPA shell for arbitrary paths: crawlers must receive a real 404.
  50. location / {
  51. try_files $uri $uri/ =404;
  52. }
  53. }