Nginx in Docker

Updated: 05 April 2024

Run the latest version of the Nginx web-server in a docker container. The default Nginx page with be at http://localhost

docker run --rm -p 80:80 --name our_ws nginx

By default, Nginx looks in /usr/share/nginx/html for files to serve. So, mount our own content at that location

docker run --rm -p 80:80 --name our_ws -v $PWD:/usr/share/nginx/html nginx

Nginx

Updated: 01 August 2026

https://www.digitalocean.com/community/tools/nginx
https://ssl-config.mozilla.org/


Validate the Nginx configuration files, from the command line

nginx -t

After a change in configuration, reload

sudo systemctl reload nginx

Restart Nginx

sudo systemctl restart nginx

See which modules (e.g. rewrite) are compiled into the binary at install time

nginx -V

Add a header from nginx conf, always, regardless of response code

add_header X-Chris-Debug "$uri" always;
add_header X-Chris-Debug "this location read" always;

Debug values of ngix variables, straight to your browser

server {
  listen 80;
  server_name haskell.ctd.gg;

  location / {
    set $debug "
    host: $host
    server_port: $server_port
    remote_addr: $remote_addr
    proxy_add_x_forwarded_for: $proxy_add_x_forwarded_for
    server_name: $server_name
    scheme: $scheme";

    add_header Content-Type text/plain;
    return 200 "$debug";
  }
}