server {
listen [::]:80 default_server;
listen 80 default_server;
server_name _;
root /var/www/static-files;
# gzip
gzip_disable "msie6";
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;
# allow safe files
location ~* \.(?:css(\.map)?|js(\.map)?|ttf|ttc|otf|eot|woff2?|svgz?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv|pdf|docx?|dotx?|docm|dotm|xlsx?|xltx?|xlsm|xltm|pptx?|potx?|pptm|potm|ppsx?)$ {
add_header Access-Control-Allow-Origin "*";
add_header Cache-Control "public";
expires 30d;
access_log off;
}
# single page application
location / {
try_files $uri $uri/ /index.html;
}
}
curl -Ss --create-dirs -o files/Helmet1.png https://hellupline.dev/uploads/gallery/Helmet1_Sign.png
echo "hello" > files/index.html
docker run --detach --name nginx-static-files \
--volume "${PWD}/static-files.conf:/etc/nginx/conf.d/default.conf" \
--volume "${PWD}/files:/var/www/static-files" \
--publish "8080:80" \
--workdir "/var/www/static-files" \
nginx
curl -SsD- -o Helmet1.png http://localhost:8080/Helmet1.png
curl -SsD- http://localhost:8080/
curl -SsD- http://localhost:8080/app
docker stop nginx-static-files
docker rm nginx-static-files