Skip to content

Instantly share code, notes, and snippets.

@mowings
Last active August 29, 2015 14:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mowings/56751734903ff64b2839 to your computer and use it in GitHub Desktop.
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
# 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