Created
September 7, 2020 09:20
-
-
Save zoubingwu/cdd45fcea8e5ea1a487cae3b279cdcab to your computer and use it in GitHub Desktop.
cors local nginx
This file contains hidden or 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
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
sendfile on; | |
keepalive_timeout 65; | |
gzip on; | |
server_names_hash_bucket_size 64; | |
map $http_upgrade $connection_upgrade { | |
default Upgrade; | |
'' close; | |
} | |
server { | |
listen 80; | |
server_name xxx.com; # set xxx.com dns to localhost in /etc/hosts and run this nginx | |
access_log path/to/access.log; | |
error_log path/to/error.log; | |
location / { | |
proxy_pass http://localhost:8080; # start front end dev server and open browser to xxx.com | |
proxy_read_timeout 120; | |
proxy_set_header Host $http_host; | |
proxy_set_header Remote-Addr $http_remote_addr; | |
proxy_set_header X-Real-IP $remote_addr; | |
# to support hot-reload | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
} | |
location /api/ { | |
proxy_pass http://realbackend; # proxy to real backend server | |
proxy_read_timeout 120; | |
proxy_set_header Host $http_host; | |
proxy_set_header Remote-Addr $http_remote_addr; | |
proxy_set_header X-Real-IP $remote_addr; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment