Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:10
Show Gist options
  • Save dacr/ff7c6af71472dc7f1a88e75151d1699f to your computer and use it in GitHub Desktop.
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/37d1a027504e166a7eb89b474e87ce18521dfa43

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