Created
August 11, 2020 07:21
-
-
Save DingoEatingFuzz/f0ab7279c9fd73ec783a15bbac0ba037 to your computer and use it in GitHub Desktop.
Running the Nomad Prototype UI with an NGINX Proxy to get around CORS
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
version: '3.8' | |
services: | |
ui: | |
image: dingoeatingfuzz/nomad-prototype-ui:latest | |
ports: | |
- '6464:6464' | |
environment: | |
NOMAD_API: 'http://localhost:8080' | |
nginx: | |
image: nginx:latest | |
volumes: | |
- type: bind | |
source: ./nginx.conf | |
target: /etc/nginx/nginx.conf | |
ports: | |
- '8080:80' |
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
events {} | |
http { | |
server { | |
location / { | |
proxy_pass http://nomad-ws; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
# CORS | |
add_header 'Access-Control-Allow-Origin' '*' always; | |
add_header 'Access-Control-Expose-Headers' '*' always; | |
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; | |
proxy_read_timeout 310s; | |
proxy_buffering off; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Origin "${scheme}://${proxy_host}"; | |
} | |
} | |
upstream nomad-ws { | |
ip_hash; | |
server <your-actual-nomad-api>:4646; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment