Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ErisDS

ErisDS/nginx.cnf Secret

Last active August 26, 2022 17:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ErisDS/3ee9f27bcdb43522f0be to your computer and use it in GitHub Desktop.
Save ErisDS/3ee9f27bcdb43522f0be to your computer and use it in GitHub Desktop.
Recommended nginx config for Ghost(Pro) subdirectory proxy. SSL is required.
server {
listen 80;
server_name <yourdomain.com>; # Replace with your domain
# include any global or shared config
# include /etc/nginx/conf/your-config-here.conf;
# redirect to SSL
return 301 https://$host$request_uri;
}
server {
listen 443 ssl default_server;
server_name <yourdomain.com>; # Replace with your domain
# Your SSL Certificate details. Replace with your own SSL setup
# ssl_certificate /path/to/cert;
# ssl_certificate_key /path/to/key;
location /blog/ {
client_max_body_size 10G; # Required for uploading large files
# Proxy Settings, all required
resolver 1.1.1.1 8.8.8.8; # Prevent caching the upstream IP - use preferred DNS resolvers or leave as default
set $ghost_url https://<yoursubdomain>.ghost.io; # Replace with your subdomain
proxy_pass $ghost_url; # Variable name must match line above, use of variable required for resolver
proxy_redirect off;
proxy_set_header Host <yoursubdomain>.ghost.io; # Replace with your subdomain
proxy_set_header X-Forwarded-Host <yourdomain.com>; # Replace with your domain
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment