Skip to content

Instantly share code, notes, and snippets.

@Wxh16144
Created July 26, 2024 06:19
Show Gist options
  • Save Wxh16144/f438f8a67dd97f54181e5b33abf742f7 to your computer and use it in GitHub Desktop.
Save Wxh16144/f438f8a67dd97f54181e5b33abf742f7 to your computer and use it in GitHub Desktop.
Docker Nginx minimal configuration
# https://www.digitalocean.com/community/tools/nginx?global.app.lang=zhCN
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
location / {
index index.html index.htm;
try_files $uri /index.html =404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 7d;
}
# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 7d;
}
# 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/rss+xml application/atom+xml image/svg+xml;
}
@Wxh16144
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment