Skip to content

Instantly share code, notes, and snippets.

@joequery
Created November 12, 2015 18:28
Show Gist options
  • Save joequery/a968e9052a2fb456a7cb to your computer and use it in GitHub Desktop.
Save joequery/a968e9052a2fb456a7cb to your computer and use it in GitHub Desktop.
VM Port forwarding config
#########################
# On host
#########################
server{
auth_basic "Restricted";
auth_basic_user_file /path/to/authfile;
server_name "~^8(?<theport>\d{3})\.vm\.domain\.com$";
location / {
set $baseport "8";
set $fullport $baseport$theport;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header Vmport $fullport;
proxy_pass http://10.50.50.50; # private IP of VM
}
}
#########################
# On guest
#########################
server{
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:$http_vmport;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment