user www-data; worker_processes auto; pid /run/nginx.pid; error_log /var/log/nginx/error.log; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/jpeg image/png image/gif; gzip_comp_level 6; gzip_min_length 1k; gzip_vary on; client_max_body_size 10M; server { listen 443 ssl; server_name cloudpure.cn; ssl_certificate /opt/key/www.cloudpure.cn.pem; ssl_certificate_key /opt/key/www.cloudpure.cn.key; return 301 https://www.cloudpure.cn$request_uri; } server { listen 443 ssl; server_name www.cloudpure.cn; ssl_certificate /opt/key/www.cloudpure.cn.pem; ssl_certificate_key /opt/key/www.cloudpure.cn.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; include /etc/nginx/default.d/*.conf; location /yunpubullet/ { proxy_pass http://127.0.0.1:8081/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location = / { root /opt/web/dist; try_files /home/index.html =404; } 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)$ { return 301 $uri/$is_args$args; } 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)/?$ { root /opt/web/dist; try_files $uri $uri/ /$1/index.html =404; } location = /order-tai { return 301 /ai/; } location = /order-tai/ { return 301 /ai/; } # Keep pre-rendered article HTML when it exists. Fall back to the SPA so # newly published articles can load by slug before the next prerender. location = /news/test { return 404; } location = /news/test/ { return 404; } location ~ ^/news/article-fe2a72(?:[^/]*)?$ { return 404; } location ~ ^/news/article-fe2a72(?:[^/]*)?/$ { return 404; } location ~ ^/news/[^/]+$ { return 301 $uri/$is_args$args; } location ~ ^/news/[^/]+/$ { root /opt/web/dist; try_files $uri $uri/ /index.html; } location = /robots.txt { root /opt/web/dist; try_files $uri =404; } location = /sitemap.xml { root /opt/web/dist; try_files $uri =404; } location /static/ { root /opt/web/dist; try_files $uri =404; expires 30d; } # Normalize all other public page URLs without a trailing slash. API, # admin, assets, uploads, and file-like URLs are intentionally excluded. location ~ ^/(?!prod-api(?:/|$)|admin(?:/|$)|static(?:/|$)|profile(?:/|$)|yunpubullet(?:/|$)|robots\.txt$|sitemap\.xml$)(?:[^/]+/)*[^/.]+$ { return 301 $uri/$is_args$args; } location /profile/ { proxy_pass http://127.0.0.1:8080/profile/; } location = /admin { return 301 /admin/; } location = /admin/ { return 302 /admin/login; } location = /admin/index.html { alias /opt/admin/dist/index.html; } location ^~ /admin/static/ { alias /opt/admin/dist/static/; try_files $uri =404; } location ^~ /admin/ { rewrite ^ /admin/index.html last; } location /prod-api { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8080; } location ~ ^/v3/api-docs/(.*) { proxy_pass http://localhost:8080/v3/api-docs/$1; } # Unknown website routes must not return the SPA shell. location / { root /opt/web/dist; try_files $uri $uri/ =404; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name cloudpure.cn www.cloudpure.cn; return 301 https://www.cloudpure.cn$request_uri; } include /etc/nginx/sites-enabled/*; }