Skip to content

Instantly share code, notes, and snippets.

@Ibmurai
Created September 11, 2024 09:45
Show Gist options
  • Save Ibmurai/6ffbe7099d8d58b3e30361d55a6ce7ba to your computer and use it in GitHub Desktop.
Save Ibmurai/6ffbe7099d8d58b3e30361d55a6ce7ba to your computer and use it in GitHub Desktop.
A basic nginx config for an SPA, including SSL config
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 443 ssl;
server_name localhest;
ssl_certificate localhest.pem;
ssl_certificate_key localhest.key;
listen 80;
gzip on;
gzip_types text/html application/javascript application/json text/css;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ $uri.html /index.html;
}
location ~* \.(?:css|js|jpg|svg)$ {
expires 30d;
add_header Cache-Control "public";
}
location ~* \.(?:json)$ {
expires 1d;
add_header Cache-Control "public";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment