Issue
I'm running nginx as a proxy for my backend services. I want to use url as http://IP:PORT/<token>/endpoint
and which should be proxied to url as http://backend/endpoint
nginx.conf file:-
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_set_header Authorization "Basic safdadfWU6cdfdvcmQ=";
}
}
Here I want to take <token>
out of the url and pass remaining endpoint to my proxy_pass server. Kindly help me.
Solution
Thank you @Richard, Your suggestions helped in solving my Question. For other people's reference, the update nginx.conf file:-
server {
listen 80;
location / {
rewrite ^/[^/]+(/.*)$ $1 break;
proxy_pass http://backend;
proxy_set_header Authorization "Basic safdadfWU6cdfdvcmQ=";
}
}
Now I'm able to use url as http://IP:PORT/<token>/endpoint
and which should be proxied to url as http://backend/endpoint
Answered By - nandal Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.