use only one config and one domain

This commit is contained in:
Jonathan Baecker 2020-09-14 18:12:13 +02:00
parent f9fec88aab
commit be63738bb1
3 changed files with 79 additions and 70 deletions

View File

@ -1,40 +0,0 @@
server {
listen 80;
server_name ffplayout-frontend.local;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
charset utf-8;
client_max_body_size 7000M; # should be desirable value
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
location / {
if ($http_origin ~ '^https?://(localhost|ffplayout-frontend\.local)') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
}
if ($request_method = OPTIONS ) {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
root /var/www/ffplayout-frontend/dist/;
}
access_log /var/log/nginx/ffplayout-frontend_access.log;
error_log /var/log/nginx/ffplayout-frontend_error.log warn;
}

71
docs/ffplayout.conf Normal file
View File

@ -0,0 +1,71 @@
server {
listen 80;
server_name ffplayout.local;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
charset utf-8;
client_max_body_size 7000M; # should be desirable value
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
location / {
if ($http_origin ~ '^https?://(localhost|ffplayout\.local)') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
}
if ($request_method = OPTIONS ) {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
root /var/www/ffplayout-frontend/dist/;
}
location ~ ^/(api|admin|auth|api-auth) {
if ($http_origin ~ '^https?://(localhost|ffplayout\.local)') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
}
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 36000s;
proxy_connect_timeout 36000s;
proxy_send_timeout 36000s;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
send_timeout 36000s;
proxy_no_cache 1;
proxy_pass http://127.0.0.1:8001;
}
location /static/ {
alias /var/www/ffplayout-api/ffplayout/static/;
}
}

View File

@ -82,19 +82,11 @@ runInstall() {
echo ""
echo "------------------------------------------------------------------------------"
echo "ffplayout api domain name (like: api.example.org)"
echo "ffplayout domain name (like: example.org)"
echo "------------------------------------------------------------------------------"
echo ""
read -p "api domain name :$ " domainApi
echo ""
echo "------------------------------------------------------------------------------"
echo "ffplayout frontend domain name (like: www.example.org)"
echo "------------------------------------------------------------------------------"
echo ""
read -p "frontend domain name :$ " domainFrontend
read -p "domain name :$ " domainFrontend
fi
if [[ ! -d /usr/local/srs ]]; then
@ -544,24 +536,10 @@ EOF
sed -i "s/User=root/User=$serviceUser/g" /etc/systemd/system/ffplayout-api.service
sed -i "s/Group=root/Group=$serviceUser/g" /etc/systemd/system/ffplayout-api.service
sed -i "s/'localhost'/'localhost', \'$domainApi\'/g" /var/www/ffplayout/ffplayout/ffplayout/settings/production.py
sed -i "s/ffplayout\\.local/$domainApi\'\n \'https\\:\/\/$domainApi/g" /var/www/ffplayout/ffplayout/ffplayout/settings/production.py
sed -i "s/'localhost'/'localhost', \'$domainFrontend\'/g" /var/www/ffplayout-api/ffplayout/ffplayout/settings/production.py
sed -i "s/ffplayout\\.local/$domainFrontend\'\n \'https\\:\/\/$domainFrontend/g" /var/www/ffplayout-api/ffplayout/ffplayout/settings/production.py
systemctl enable ffplayout-api.service
if [[ $installNginx == 'y' ]]; then
cp docs/ffplayout-api.conf "$nginxConfig/"
origin=$(echo "$domainApi" | sed 's/\./\\\\./g')
sed -i "s/ffplayout-api.local/$domainApi/g" $nginxConfig/ffplayout-api.conf
sed -i "s/ffplayout-api\\\.local/$origin/g" $nginxConfig/ffplayout-api.conf
if [[ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]]; then
ln -s $nginxConfig/ffplayout-api.conf /etc/nginx/sites-enabled/
fi
fi
systemctl start ffplayout-api.service
fi
@ -589,15 +567,15 @@ EOF
chown $serviceUser. -R /var/www
if [[ $installNginx == 'y' ]]; then
cp docs/ffplayout-frontend.conf "$nginxConfig/"
cp docs/ffplayout.conf "$nginxConfig/"
origin=$(echo "$domainFrontend" | sed 's/\./\\\\./g')
sed -i "s/ffplayout-frontend.local/$domainFrontend/g" $nginxConfig/ffplayout-frontend.conf
sed -i "s/ffplayout-frontend\\\.local/$origin/g" $nginxConfig/ffplayout-frontend.conf
sed -i "s/ffplayout.local/$domainFrontend/g" $nginxConfig/ffplayout.conf
sed -i "s/ffplayout\\\.local/$origin/g" $nginxConfig/ffplayout.conf
if [[ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]]; then
ln -s $nginxConfig/ffplayout-frontend.conf /etc/nginx/sites-enabled/
ln -s $nginxConfig/ffplayout.conf /etc/nginx/sites-enabled/
fi
fi
fi