server {
server_name test.com www.test.com;
root /var/www/promo/nextjs-coupon/public;
location /_next/static/ {
alias /var/www/promo/nextjs-coupon/.next/static;
expires 1d;
add_header Cache-Control "public, immutable";
}
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
# Директива для обслуживания статических файлов
expires 1d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
error_page 404 /404.html;
location = /404.html {
internal;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/besplatno-skin.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/besplatno-skin.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
server_name admin.test.com www.admin.test.com;
location / {
proxy_pass http://test.com:1337;
proxy_set_header Host $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;
}
}
server {
if ($host = www.test.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = besplatno-skin.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name test.com www.test.com;
listen 80;
return 404; # managed by Certbot
}