| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- server {
- listen 80;
- server_name apidoc.proginn.com;
- set $temp_request_id $http_x_request_id;
- if ($temp_request_id = "") {
- set $temp_request_id $request_id;
- }
- location / {
- limit_req zone=byip burst=10;
- proxy_pass http://10.200.200.202:3000/;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $http_x_real_ip;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- # proxy_set_header X-Forwarded-Proto $scheme;
- # proxy_set_header X-Scheme $scheme;
- proxy_set_header Origin $http_origin;
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection $connection_upgrade;
- #=========================CORS nginx配置=============================
- if ($http_origin ~* (https?://apidoc\.proginn\.com(:[0-9]+)?)$) {
- set $cors "true";
- }
- if ($request_method = 'OPTIONS') {
- set $cors "${cors}options";
- }
- if ($request_method = 'GET') {
- set $cors "${cors}get";
- }
- if ($request_method = 'POST') {
- set $cors "${cors}post";
- }
- if ($cors = "trueget") {
- add_header 'Access-Control-Allow-Origin' "$http_origin";
- add_header 'Access-Control-Allow-Credentials' 'true';
- }
- if ($cors = "truepost") {
- add_header 'Access-Control-Allow-Origin' "$http_origin";
- add_header 'Access-Control-Allow-Credentials' 'true';
- }
- if ($cors = "trueoptions") {
- add_header 'Access-Control-Allow-Origin' "$http_origin";
- # add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Credentials' 'true';
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since,X-CSRF-TOKEN';
- add_header 'Content-Length' 0;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- # return 204;
- return 200;
- }
- }
- }
|