Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:18
Show Gist options
  • Select an option

  • Save dacr/ff7c6af71472dc7f1a88e75151d1699f to your computer and use it in GitHub Desktop.

Select an option

Save dacr/ff7c6af71472dc7f1a88e75151d1699f to your computer and use it in GitHub Desktop.
nginx cheat sheet / published by https://github.com/dacr/code-examples-manager #52ba987c-2150-40c7-942d-7af369a39a28/3dbec4452ccb41ad01d8b14ce62a76f6cef4625e

nginx cheat sheet

Add authentication to elasticsearch

server {
    listen 80;
    listen [::]:80;
    server_name  domain.org;

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/htpasswd-domain-org.users;

    location / {
        proxy_pass http://127.0.0.1:5601;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Add user for basic authentication

echo "username:$(openssl passwd -apr1)" | sudo tee -a /etc/nginx/htpasswd.users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment