A Simple Configuration to Host Static Files with Alpine Nginx

nginx
2022-09-09 07:37 (4 years ago)
A Simple Configuration to Host Static Files with Alpine Nginx

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;
}
}
Please rate this article (No signup or login required)
Currently unrated

Related posts

The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive