Last active
September 23, 2024 16:57
-
-
Save zettca/bba8739695959883ce36e14599a3c669 to your computer and use it in GitHub Desktop.
nginx static file server
This file contains 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
server { | |
listen 80; | |
server_name localhost; | |
root /usr/share/nginx/html; | |
index index.html; | |
gzip on; | |
gzip_min_length 256; | |
gzip_types text/plain text/css application/javascript application/json; | |
location / { | |
autoindex on; | |
default_type text/html; | |
} | |
# Generic location for any sub-path | |
location ~ ^/([^/]+)/ { | |
try_files $uri /$1/index.html =404; | |
} | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run for the
public/
sub-directory withdocker
or with docker-compose: