Skip to content

Instantly share code, notes, and snippets.

@rkaneko
Created October 3, 2017 10:08
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 rkaneko/19f9528fd6b53af4d8769e858904c728 to your computer and use it in GitHub Desktop.
Save rkaneko/19f9528fd6b53af4d8769e858904c728 to your computer and use it in GitHub Desktop.
Dockerized nginx's proxy config example using variables for proxy_pass
server {
listen 80 default_server;
# real_ip_header X-Forwarded-For
# server_name localhost;
location ~ ^/graphql(.*) {
# see https://stackoverflow.com/questions/35744650/docker-network-nginx-resolver
resolver 127.0.0.11 ipv6=off;
set $target http://${SOME_HOST}:${SOME_PORT}/graphql;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass $target$1$is_args$args;
}
}
@rkaneko
Copy link
Author

rkaneko commented Oct 3, 2017

Prerequisites

  • Using envsubst for replacement environment variables when running docker container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment