Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

server {
  listen 8080;
  location / {
    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.

share|improve this question
up vote 2 down vote accepted

You can do it via simple http auth

Example location section

        location /protected/ {
        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)

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.