A Simple Configuration to Host Static Files with Alpine Nginx

nginx
2022-09-09 16:37 (2 years ago) ytyng

In the end, I decided to overwrite the original nginx.conf.

Dockerfile

FROM alpine:3.16

RUN apk --no-cache add nginx

COPY nginx.conf /etc/nginx/nginx.conf
COPY html /var/www/localhost/htdocs

EXPOSE 80
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]

nginx.conf

# /etc/nginx/nginx.conf
user nginx;
# worker_processes auto;
worker_processes 1;

pcre_jit on;
error_log /dev/stderr warn;

events {
worker_connections 128;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
client_max_body_size 1m;
sendfile on;
tcp_nopush on;
gzip_vary on;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
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 /dev/stdout main;

server {
root /var/www/localhost/htdocs;
}
}
Current rating: 1
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Comments

Archive

2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011