Last active
August 29, 2015 14:03
-
-
Save mowings/56751734903ff64b2839 to your computer and use it in GitHub Desktop.
Generic lxc-container nginx vhost. Access web services in an lxc container generically
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
# Allows you to specify just a container, or to prepend | |
# a port to get to something not running on 80 | |
# ie, http://foo, or http://p9200.foo | |
# Obviously, you still need a host lookup mechanism for these | |
server { | |
listen 80 default_server; | |
server_name "~^(p(?<port>\d+)\.)?(?<container>[^\.]+)"; | |
location / { | |
if ($port = '') { | |
set $port 80; | |
} | |
resolver 10.0.3.1; | |
proxy_pass http://$container:$port; | |
proxy_set_header Host $host; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment