Is there a way to join two almost identical server definitions into one but still have different proxy_pass
value which depends on server name?
server_name
and proxy_pass
are the only differences between those two.
Tried with
proxy_pass http://$server_name:8080;
but no success.
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name localhost thevegcat.lan;
root e:/projects/TheVegCat/src/main/resources/static/;
ssl_certificate e:/projects/TheVegCat/ssl/CA/localhost/localhost.crt;
ssl_certificate_key e:/projects/TheVegCat/ssl/CA/localhost/localhost.decrypted.key;
add_header Strict-Transport-Security "max-age=10368000; includeSubDomains" always;
gzip on;
gzip_min_length 512;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml text/css application/javascript application/json;
location / {
add_header Strict-Transport-Security "max-age=10368000; includeSubDomains" always;
proxy_pass http://localhost:8080;
}
location ~ ^(.+)\.(ico|png|xml|json)$ {
expires 1y;
alias e:/projects/TheVegCat/src/main/resources/static/favicon/;
try_files $1.$2 $1.$2/;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name veganskivodic.thevegcat.lan;
root e:/projects/TheVegCat/src/main/resources/static/;
ssl_certificate e:/projects/TheVegCat/ssl/CA/localhost/localhost.crt;
ssl_certificate_key e:/projects/TheVegCat/ssl/CA/localhost/localhost.decrypted.key;
add_header Strict-Transport-Security "max-age=10368000; includeSubDomains" always;
gzip on;
gzip_min_length 512;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml text/css application/javascript application/json;
location / {
add_header Strict-Transport-Security "max-age=10368000; includeSubDomains" always;
proxy_pass http://veganskivodic.thevegcat.lan:8080;
}
location ~ ^(.+)\.(ico|png|xml|json)$ {
expires 1y;
alias e:/projects/TheVegCat/src/main/resources/static/favicon/;
try_files $1.$2 $1.$2/;
}
}