---
slug: "docker-nginx-simple-static-hosting"
title: "A Simple Configuration to Host Static Files with Alpine Nginx"
description: "Things to try when a Mac HDMI display occasionally freezes — change the refresh rate with `displayplacer`, reseat the cable, etc."
url: "https://www.ytyng.com/en/blog/docker-nginx-simple-static-hosting"
publish_date: "2022-09-09T07:37:30Z"
created: "2022-09-09T07:37:30Z"
updated: "2026-05-11T13:21:48.798Z"
categories: ["nginx"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/953b358aaf3c4d72927e95c2049b5ee2.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# A Simple Configuration to Host Static Files with Alpine Nginx

<p>In the end, I decided to overwrite the original nginx.conf.</p>
<h3>Dockerfile</h3>
<pre>FROM alpine:3.16<br /><br />RUN apk --no-cache add nginx<br /><br />COPY nginx.conf /etc/nginx/nginx.conf<br />COPY html /var/www/localhost/htdocs<br /><br />EXPOSE 80<br />CMD ["/usr/sbin/nginx", "-g", "daemon off;"]</pre>
<h3>nginx.conf</h3>
<pre># /etc/nginx/nginx.conf<br />user nginx;<br /># worker_processes auto;<br />worker_processes 1;<br /><br />pcre_jit on;<br />error_log /dev/stderr warn;<br /><br />events {<br /> worker_connections 128;<br />}<br /><br />http {<br />  include /etc/nginx/mime.types;<br />  default_type application/octet-stream;<br />  server_tokens off;<br />  client_max_body_size 1m;<br />  sendfile on;<br />  tcp_nopush on;<br />  gzip_vary on;<br />  map $http_upgrade $connection_upgrade {<br />    default upgrade;<br />    '' close;<br />  }<br />  log_format main '$remote_addr - $remote_user [$time_local] "$request" '<br />  '$status $body_bytes_sent "$http_referer" '<br />  '"$http_user_agent" "$http_x_forwarded_for"';<br />  access_log /dev/stdout main;<br /><br />  server {<br />    root /var/www/localhost/htdocs;<br />  }<br />}</pre>
