1

I have nginx running on simple ubuntu VPS that acts like a simple HTTP proxy:

server {
  listen 8080;
  location / {
    resolver 8.8.8.8;
    proxy_pass http://$http_host$uri$is_args$args;
  }
}

All works fine, but anyone can connect to this proxy :(. Is i any easy way to add some login/password to it? HTTP basic/digest/whatever will do.

2 Answers 2

2

You can do it via simple http auth

Example location section

        location /protected/ {
        proxy_pass http://192.168.1.1:1111;
        proxy_set_header Host $http_host;
        auth_basic            "Restricted-plz-auth-urself";
        auth_basic_user_file  /etc/nginx/passwds/htpasswd_protected;
    }

And add a password file to the path specified above, you may create it via htpasswd utility (I think apache2-utils package has this)

1

You can use auth basic, if you have this module compiled in.

like: auth_basic "closed site"; auth_basic_user_file htpasswd;

where htpasswd consist of user:password

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .