Browse Source

add scripts to create nginx virtual host for service

master
Adrian Malacoda 9 months ago
parent
commit
b794c5e8a9
  1. 27
      nginx.conf.template
  2. 26
      nginxify

27
nginx.conf.template

@ -0,0 +1,27 @@
server {
listen 80;
listen [::]:80;
server_name @SERVER_NAME@;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
client_max_body_size 100G;
server_name @SERVER_NAME@;
access_log /var/log/nginx/@SERVER_NAME@/access.log;
error_log /var/log/nginx/@SERVER_NAME@/error.log;
location /.well-known/ {
root /var/www/html/;
try_files $uri $uri/ =404;
}
location / {
proxy_pass http://127.0.0.1:@PORT@/;
}
}

26
nginxify

@ -0,0 +1,26 @@
#!/bin/bash
SERVER_NAME=$1
PORT=$2
NGINX_CONFIG=/etc/nginx
AVAILABLE_SITES="$NGINX_CONFIG/sites-available"
ENABLED_SITES="$NGINX_CONFIG/sites-enabled"
NGINX_CONF_TEMPLATE=nginx.conf.template
NGINX_CONF_NAME="$SERVER_NAME.conf"
NGINX_LOGS=/var/log/nginx
cp $NGINX_CONF_TEMPLATE "$AVAILABLE_SITES/$NGINX_CONF_NAME"
cd $AVAILABLE_SITES
sed -i "s/@SERVER_NAME@/$SERVER_NAME/g" $NGINX_CONF_NAME
sed -i "s/@PORT@/$PORT/g" $NGINX_CONF_NAME
cd $ENABLED_SITES
ln -s "../sites-available/$NGINX_CONF_NAME" .
mkdir -p "$NGINX_LOGS/$SERVER_NAME"
service nginx reload
Loading…
Cancel
Save