90 lines
2.8 KiB
Nginx Configuration File
90 lines
2.8 KiB
Nginx Configuration File
|
|
server {
|
||
|
|
listen 80;
|
||
|
|
server_name hotwives.com.br www.hotwives.com.br;
|
||
|
|
|
||
|
|
# Redirecionar para HTTPS
|
||
|
|
return 301 https://$server_name$request_uri;
|
||
|
|
}
|
||
|
|
|
||
|
|
server {
|
||
|
|
listen 443 ssl http2;
|
||
|
|
server_name hotwives.com.br www.hotwives.com.br;
|
||
|
|
|
||
|
|
# Certificados SSL (certbot irá configurar automaticamente)
|
||
|
|
# ssl_certificate /etc/letsencrypt/live/hotwives.com.br/fullchain.pem;
|
||
|
|
# ssl_certificate_key /etc/letsencrypt/live/hotwives.com.br/privkey.pem;
|
||
|
|
|
||
|
|
# Configurações SSL
|
||
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||
|
|
ssl_prefer_server_ciphers on;
|
||
|
|
|
||
|
|
# Logs
|
||
|
|
access_log /var/log/nginx/hotwives-access.log;
|
||
|
|
error_log /var/log/nginx/hotwives-error.log;
|
||
|
|
|
||
|
|
# Frontend Next.js
|
||
|
|
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;
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
# Backend API
|
||
|
|
location /api {
|
||
|
|
proxy_pass http://localhost:3001;
|
||
|
|
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;
|
||
|
|
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;
|
||
|
|
|
||
|
|
# CORS headers
|
||
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||
|
|
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
|
||
|
|
|
||
|
|
if ($request_method = 'OPTIONS') {
|
||
|
|
return 204;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Socket.IO
|
||
|
|
location /socket.io {
|
||
|
|
proxy_pass http://localhost:3001;
|
||
|
|
proxy_http_version 1.1;
|
||
|
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
|
proxy_set_header Connection "upgrade";
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
# Uploads - servir arquivos estáticos
|
||
|
|
location /uploads {
|
||
|
|
alias /var/www/hotwives/backend/uploads;
|
||
|
|
expires 30d;
|
||
|
|
add_header Cache-Control "public, immutable";
|
||
|
|
}
|
||
|
|
|
||
|
|
# Tamanho máximo de upload
|
||
|
|
client_max_body_size 10M;
|
||
|
|
|
||
|
|
# Compressão Gzip
|
||
|
|
gzip on;
|
||
|
|
gzip_vary on;
|
||
|
|
gzip_min_length 1024;
|
||
|
|
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
|
||
|
|
}
|
||
|
|
|