Skip to content

Instantly share code, notes, and snippets.

@webNeat
Created March 7, 2019 20:02
Show Gist options
  • Save webNeat/f42b0f979550f4f7233521a2dd3a1565 to your computer and use it in GitHub Desktop.
Save webNeat/f42b0f979550f4f7233521a2dd3a1565 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if [ "$#" -ne 2 ]; then
echo 'nginx-associate-port-to-domain [port] [domain]'
exit 1
fi
cat <<EOF > "/etc/nginx/sites-available/$2"
server
{
listen 80;
listen [::]:80;
server_name $2;
location /
{
proxy_pass http://127.0.0.1:$1;
include /etc/nginx/proxy_params;
}
}
EOF
ln -s "/etc/nginx/sites-available/$2" "/etc/nginx/sites-enabled/$2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment