server { server_name server.gdchat.cn; server_tokens off; #large_client_header_buffers 4 32k; client_max_body_size 50M; charset utf-8; index index.html; # 启动SSL及证书匹配 ###################################################### listen 443 ssl default_server; # managed by Certbot ssl_certificate /etc/letsencrypt/live/gdchat.cn/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/gdchat.cn/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot # 启用OCSP stapling ###################################################### ssl_stapling on; ssl_stapling_verify on; # valid表示缓存5分钟 #resolver 8.8.8.8 8.8.4.4 valid=300s; resolver 202.96.128.143 114.114.114.114 valid=300s; # 网络超时时间 resolver_timeout 5s; # 启动Gzip Json模式 ###################################################### gzip_http_version 1.0; # gzip支持http协议 proxy 必须用 gzip on; gzip_vary on; gzip_proxied any; gzip_static on; gzip_comp_level 4; gzip_min_length 256; gzip_buffers 4 8k; gzip_types text/html text/plain application/javascript application/x-javascript text/css application/xml application/json; # Common Api For Nova Cloud To DIY RESTful services location /api { # # Wide-open CORS config for nginx # if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # # Custom headers and headers various browsers *should* be OK with but aren't # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; # # Tell client that this pre-flight info is valid for 20 days # add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; } if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; } rewrite ^/(.*)$ /$1 break; proxy_pass https://server.fmode.cn/api; } location /api/apig/face/match { # # Wide-open CORS config for nginx # if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # # Custom headers and headers various browsers *should* be OK with but aren't # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin'; # # Tell client that this pre-flight info is valid for 20 days # add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; } if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; } rewrite ^/(.*)$ /$1 break; proxy_pass https://server.fmode.cn/api/apig/face/match; } location /api/novaql { # # Wide-open CORS config for nginx # #add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, POST, DELETE, OPTIONS'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Headers, Access-Control-Request-Method, Access-Control-Request-Headers,Authorization'; rewrite ^/(.*)$ /$1 break; proxy_pass https://server.fmode.cn/api; } location /{ # # Wide-open CORS config for nginx # # add_header 'Access-Control-Allow-Origin' '*'; # add_header 'Access-Control-Allow-Credentials' 'true'; # # set back end proxy # proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass https://server.fmode.cn/; proxy_redirect off; } }