Answer the question
In order to leave comments, you need to log in
How to wrap a proxied request to api in auth_basic (embed login and password b64)?
Nginx has to proxy the request with api. But on the api server authorization login password( auth_basic).
I use for early development - security is not important I
used this setting (does not help - it still asks for a password):
upstream app_db2{
server 192.168.1.66:8890;
keepalive 16;
}
server {
# listen 80;
server_name db2-dev.com;
access_log /var/log/nginx/db2.log;
location /api {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://dev1.com/api/v0.1;
proxy_set_header Authorization "Basic ***"; #*** -логин:пароль в base64
# default_type application/json;
# return 200 '{"code":"1", "message": "Unknown Error"}';
}
location / {
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;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_db2/;
proxy_redirect off;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question