0% found this document useful (0 votes)
6 views2 pages

Nginx Pool Table

This document is a configuration file for an Nginx server setup, detailing how to redirect HTTP traffic to HTTPS and set up SSL certificates using Certbot. It includes security headers, Gzip compression settings, and specific locations for serving a payment page and an admin dashboard built with React. Additionally, it ensures that hidden files like .env are blocked from access.

Uploaded by

mwihia414
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Nginx Pool Table

This document is a configuration file for an Nginx server setup, detailing how to redirect HTTP traffic to HTTPS and set up SSL certificates using Certbot. It includes security headers, Gzip compression settings, and specific locations for serving a payment page and an admin dashboard built with React. Additionally, it ensures that hidden files like .env are blocked from access.

Uploaded by

mwihia414
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# /etc/nginx/sites-available/pool-table

# ── Replace [Link] with your actual domain ──────────────────────────


#
# After setting up:
# sudo ln -s /etc/nginx/sites-available/pool-table /etc/nginx/sites-enabled/
# sudo nginx -t
# sudo systemctl reload nginx
# sudo certbot --nginx -d [Link] -d [Link]

# Redirect HTTP → HTTPS


server {
listen 80;
listen [::]:80;
server_name [Link] [Link];
return 301 [Link]
}

# Main HTTPS server


server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;

# ── SSL (Certbot fills these in automatically) ──────────────────────────


ssl_certificate /etc/letsencrypt/live/[Link]/[Link];
ssl_certificate_key /etc/letsencrypt/live/[Link]/[Link];
include /etc/letsencrypt/[Link];
ssl_dhparam /etc/letsencrypt/[Link];

# ── Security Headers ────────────────────────────────────────────────────


add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"
always;
add_header X-Frame-Options "DENY"
always;
add_header X-Content-Type-Options "nosniff"
always;
add_header X-XSS-Protection "1; mode=block"
always;
add_header Referrer-Policy "strict-origin-when-cross-origin"
always;

# ── Gzip ────────────────────────────────────────────────────────────────
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json
application/javascript application/xml+rss
application/atom+xml image/svg+xml;

# ── Customer Payment Page (/[Link]) ────────────────────────────────────


# This is served by [Link] from backend/public/
location /[Link] {
proxy_pass [Link]
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}

# ── Admin Dashboard (React SPA) ──────────────────────────────────────────


# Serves the built React app. All routes fall back to [Link].
root /var/www/pool-table/admin-dashboard/dist;

location / {
try_files $uri $uri/ /[Link];

# Cache static assets aggressively


location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}

# ── Block .env and hidden files ──────────────────────────────────────────


location ~ /\. {
deny all;
}
}

You might also like