Last active
July 9, 2024 12:06
-
-
Save rootiest/c55aeeea8072d760813f59e56fff2c7c to your computer and use it in GitHub Desktop.
Rootiest Nginx Sample Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Template nginx config | |
# https://notes.rootiest.dev | |
# Define the server IP and ports here. | |
upstream notes { | |
# Name the upstream and zone after the service | |
zone notes 64k; | |
# Define the server IP and port | |
server 100.73.247.145:5230; | |
# Or path | |
# server /notes/index.html; | |
keepalive 2; | |
} | |
# Redirect HTTP to HTTPS | |
server { | |
if ($host ~ ^[^.]+\.rootiest\.dev$) { | |
return 301 https://$host$request_uri; | |
} | |
# Domain goes here | |
if ($host = notes.rootiest.dev) { | |
return 301 https://$host$request_uri; | |
} | |
listen 80; | |
listen [::]:80; | |
# Domain goes here | |
server_name notes.rootiest.dev; | |
} | |
# Main server block | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
# Domain goes here | |
server_name notes.rootiest.dev; | |
location / { | |
# upstream name goes here | |
proxy_pass http://notes; | |
proxy_set_header Host $http_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; | |
proxy_redirect off; | |
proxy_read_timeout 120; | |
proxy_connect_timeout 10; | |
gzip off; | |
} | |
# Optional Logs | |
access_log /var/log/nginx/notes.rootiest.dev-access.log; | |
error_log /var/log/nginx/notes.rootiest.dev-error.log; | |
# SSL Certs and config | |
include /etc/nginx/snippets/ssl.conf; | |
#ssl_certificate /etc/letsencrypt/live/rootiest.dev/fullchain.pem; | |
#ssl_certificate_key /etc/letsencrypt/live/rootiest.dev/privkey.pem; | |
# Only allow local access | |
#include /etc/nginx/snippets/local.conf; | |
#allow 192.168.86.0/24; | |
#allow fd7a:115c:a1b0:cd12:3456:cd96:4321:1a1e; | |
# etc... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment