Skip to content

Instantly share code, notes, and snippets.

@bydmm
Last active August 29, 2015 14:17
Show Gist options
  • Save bydmm/015f736ea626eb6a5ae3 to your computer and use it in GitHub Desktop.
Save bydmm/015f736ea626eb6a5ae3 to your computer and use it in GitHub Desktop.
Authentication with nginx auth_basic
sudo apt-get install apache2-utils
sudo htpasswd -c /home/ubuntu/user.pwd username
sudo vim /etc/nginx/sites-available/logio
server {
    listen 80;
    server_name bole_live;

    location / {
        rewrite ^/(.*) /$1 break;
        proxy_ignore_client_abort on;
        proxy_pass http://localhost:28778;
        proxy_redirect http://localhost:28778 http://bole_live/;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        auth_basic "Log Authentication";
        auth_basic_user_file /home/ubuntu/user.pwd;

        # Socket.IO Support
        # proxy_http_version 1.1;
        # proxy_set_header Upgrade $http_upgrade;
        # proxy_set_header Connection "upgrade";
    }
}
sudo ln -nfs /etc/nginx/sites-available/logio /etc/nginx/sites-enabled/logio
sudo service nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment