<div dir="ltr"><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">Dear Nginx Users,</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">I have a scenario that whenever a user hits the website (<a href="https://abc.test.com/" rel="nofollow noreferrer" target="_blank" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">https://abc.test.com</a>), it should re-direct to the sub-path (/xxx/yyy/) of the website (ex: <a href="https://abc.test.com/xxx/yyy" rel="nofollow noreferrer" target="_blank" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">https://abc.test.com/xxx/yyy</a>).</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">So re-direction to a website's sub-path (<a href="https://abc.test.com/xxx/yyy" rel="nofollow noreferrer" target="_blank" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">https://abc.test.com/xxx/yyy</a>) is working.</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">I have implemented http basic auth, so whenever the user is re-directed to sub-path /xxx/yyy/, the basic auth should come into effect and then the website has to be re-directed.</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">The issue is basic auth is not coming into effect before re-directing to the web-site's sub-path it just re-directs.</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">This is how my nginx config looks like</p><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px;padding:12px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px"><font face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif"> listen 443 ssl;
server_name <a href="http://aa.bb.com/" target="_blank">aa.bb.com</a>;
set $backend "<a href="https://abc.test.com:8080/" target="_blank">https://abc.test.com:8080/</a>";
location / {
proxy_pass $backend;
proxy_pass_header Authorization;
auth_basic "Access Denied or Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
return 301 <a href="https://abc.test.com:8080/xxx/yyy/" target="_blank">https://abc.test.com:8080/xxx/yyy/</a>;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host <a href="http://aa.bb.com/" target="_blank">aa.bb.com</a>;
client_max_body_size 10m;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 900;
}
}
</font><font face="arial, sans-serif">If you see above in the location block i am using basic auth just before the re-direction, but the basic auth is not in effect.
Any ideas or suggestions are highly appreciated.</font></code></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px;padding:12px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px"><font face="arial, sans-serif">nginx version: nginx/1.16.1<br></font></code></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px;padding:12px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px"><font face="arial, sans-serif">Thanks & Regards,<br>Majid M A</font></code></pre></div>