-
-
Save dhirajforyou/0b989e2562c90c8217ef0ec64ca3bf2c to your computer and use it in GitHub Desktop.
Internal redirect to another domain with proxy_pass and Nginx
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
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