Skip to content

Instantly share code, notes, and snippets.

@DingoEatingFuzz
Created August 11, 2020 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DingoEatingFuzz/f0ab7279c9fd73ec783a15bbac0ba037 to your computer and use it in GitHub Desktop.
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
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'
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