Created
August 28, 2018 02:37
-
-
Save yzf/8b9cddea55c15cba856877c34b7480c5 to your computer and use it in GitHub Desktop.
nginx跨域
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
index index.html index.htm index.nginx-debian.html; | |
location /api { | |
proxy_pass http://127.0.0.1:8080; | |
add_header Access-Control-Allow-Origin *; | |
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; | |
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; | |
if ($request_method = 'OPTIONS') { | |
return 204; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment