Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Re: How to allow access to a URL from only a selected IP

$
0
0
The following appears to almost work

server {
listen 80;
server_name 192.168.1.25;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name 192.168.1.25;

root /var/www/html;

index index.html index.htm index.nginx-debian.html;

ssl_certificate /etc/ssl/openhab.crt;
ssl_certificate_key /etc/ssl/openhab.key;

# location ~ paper {
# allow 192.168.1.52;
# deny all;
# }


location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

auth_basic "Username and Password Required";
auth_basic_user_file /etc/nginx/.htpasswd;

}

}

When

# location ~ paper {
# allow 192.168.1.52;
# deny all;
# }

is uncommented, nothing access any url with "paper" in the address. I tried merging some of the settings from the other location block into the paper one but could not get that to work either.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>