I have a Flask restful service and I want to protect one particular route with username/password using nginx. When user enters the url he gets an excel file(report). I have followed this tutorial to create simple authentication. I've added the parameters mentioned there, but to no effect. Here is my config file:
server {
listen 80;
real_ip_header X-Forwarded-For;
set_real_ip_from 127.0.0.1;
server_name localhost;
root /var/www/html/psycho-test-rest/psycho_front/dist;
location /tests/get_all_users {
include uwsgi_params;
uwsgi_pass unix:/var/www/html/psycho-test-rest/socket.sock;
uwsgi_modifier1 30;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location ~ ^/(tests|CRUD)/ {
include uwsgi_params;
uwsgi_pass unix:/var/www/html/psycho-test-rest/socket.sock;
uwsgi_modifier1 30;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
/tests/get_all_users is the location I want to protect. When I enter the url in browser I get the file, but nginx does not ask for a password. Is there a problem with config file? I am not sure if it matters but https is not yet enabled. I was thinking about setting it up after I set up password for this route.
I am deploying on ubuntu 16.04.
答案 0 :(得分:0)
使用像" var newList = result.Select(r=>r+"-aaa").ToList();
"在那条路线上:
login_required