Fixing nginx configuration when server_name is not passed

This commit is contained in:
Ricardo Paes
2022-02-15 14:54:21 -03:00
parent 1e8dc0cce5
commit ca42c867cd
5 changed files with 20 additions and 7 deletions

View File

@@ -19,6 +19,7 @@ _addSslConfig() {
echo "ssl_certificate ${SSL_CERTIFICATE};" >> ${FILE_CONF};
echo "ssl_certificate_key ${SSL_CERTIFICATE_KEY};" >> ${FILE_CONF};
else
echo 'listen 80;' >> ${FILE_CONF};
echo "ssl ${1} not found >> ${SSL_CERTIFICATE} -> ${SSL_CERTIFICATE_KEY}"
fi;
}

View File

@@ -1,20 +1,27 @@
include include.d/ssl-redirect.conf;
upstream backend {
server {{ .Env.URL_BACKEND }};
}
server {
listen 80;
index index.html;
root /var/www/public/;
server_name {{ default .Env.FRONTEND_SERVER_NAME "_" }};
{{ if .Env.FRONTEND_SERVER_NAME }}
server_name {{ .Env.FRONTEND_SERVER_NAME }};
{{else}}
server_name _;
{{end}}
include sites.d/frontend.conf;
include include.d/letsencrypt.conf;
}
{{if .Env.BACKEND_SERVER_NAME}}
server {
listen 80;
server_name {{ default .Env.BACKEND_SERVER_NAME "_" }};
server_name {{ .Env.BACKEND_SERVER_NAME }};
include sites.d/backend.conf;
include include.d/letsencrypt.conf;
}
}
{{end}}

View File

@@ -0,0 +1,5 @@
server {
listen 80;
listen [::]:80;
return 302 https://$host$request_uri;
}

View File

@@ -8,4 +8,4 @@ location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}

View File

@@ -8,4 +8,4 @@ location /static {
include include.d/allcache.conf;
}
include "include.d/spa.conf";
include "include.d/spa.conf";