Last active
November 24, 2016 05:05
-
-
Save pokutuna/5ad6b04ada0d9991a80f11b2dfbfe903 to your computer and use it in GitHub Desktop.
nginx proxy_set_header
This file contains hidden or 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
use strict; | |
use warnings; | |
my $app = sub { | |
my ($env) = @_; | |
return [ 200, [ 'Content-Type' => 'text/plain' ], [ "HTTP_HOST: $env->{HTTP_HOST}" ] ]; | |
}; |
This file contains hidden or 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
#!/bin/bash | |
trap 'kill $(jobs -p) && sudo nginx -s quit' EXIT | |
sudo nginx -c $PWD/nginx.conf | |
plackup & | |
open 'http://localhost:5001' | |
open 'http://localhost:5002' | |
wait |
This file contains hidden or 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 { | |
worker_connections 1024; | |
} | |
http { | |
server { | |
listen 5001; | |
proxy_set_header Host header1; | |
proxy_set_header Host header2; | |
location / { | |
proxy_pass http://localhost:5000; | |
# => HTTP_HOST: header1, header2 | |
} | |
} | |
server { | |
listen 5002; | |
proxy_set_header Host header1; | |
location / { | |
proxy_set_header Host header2; | |
proxy_pass http://localhost:5000; | |
# => HTTP_HOST: header2 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment