Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dhirajforyou/0b989e2562c90c8217ef0ec64ca3bf2c to your computer and use it in GitHub Desktop.
Save dhirajforyou/0b989e2562c90c8217ef0ec64ca3bf2c to your computer and use it in GitHub Desktop.
Internal redirect to another domain with proxy_pass and Nginx
server
{
listen 80;
server_name a.com b.com c.com;
location ~* ^/comment/(.*) {
proxy_set_header HOST shared.com;
# $1 - stores capture from the location on top
# $is_args will return ? if there are query params
# $args stores query params
proxy_pass http://comment/$1$is_args$args;
}
}
server {
listen 80;
server shared.com;
location / {
# Proxy to some app handler
}
}
upstream comment {
server localhost; # or any other host essentially
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment