Skip to content

Instantly share code, notes, and snippets.

@Pinjontall94
Created June 13, 2025 19:41
Show Gist options
  • Select an option

  • Save Pinjontall94/cb41c50365860dc2b92b946cef9605c4 to your computer and use it in GitHub Desktop.

Select an option

Save Pinjontall94/cb41c50365860dc2b92b946cef9605c4 to your computer and use it in GitHub Desktop.
Nginx boilerplate
# nginx automatically determines # of processes
worker_processes auto;
# each worker can handle this many active connections
events {
worker_connections 1024;
}
# handle http requests
http {
# handle .html as web pages, .jpg as images, etc.
include mime.types;
# download if not otherwise recognized as a known mime type
default_type application/octet-stream;
# enable sendfile syscall, for more efficient file serving
sendfile on;
# default timeout 65 seconds
keepalive_timeout 65;
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/mydomainname.com.crt;
ssl_certificate_key /etc/nginx/ssl/mydomainname.com.key;
root /var/www/html;
index index.html index.htm;
# specify name this server block will respond to
server_name mydomainname.com;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80;
server_name mydomainname.com
# redirect all http reqs to https
return 301 https://$host$request_uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment