I'm trying to set up nginx to let the name node of a Hadoop based cluster that I set up effectively redirect to the different user interfaces surrounding Hadoop based off of the file extension on the url. For simplicity, say that
firstnode.com corresponds to the main node of my cluster
stormnode.com corresponds to the node running storm, and the UI is accessible at port 8080.
Then, the ideal redirection would be http://firstnode.com/storm ->http://stormnode.com:8080.
I have tried editing my Nginx configuration file such that I end up with something like each of the following:
server{
listen 80;
server_name firstnode.com;
location /storm{
proxy_pass secondnode.com:8080;
}
}
as well as
server{
listen 80;
server_name firstnode.com;
location /storm{
return 301 $scheme://secondnode.com:8080$request_uri;
}
}
as well as equivalent statements to the latter using regular expressions. Unfortunately, the closest that I have gotten is redirecting firstnode.com/storm to secondnode.com:8080/storm. I would greatly appreciate any advice on how to rewrite the URL through nginx's config files without passing the file extension/path (aka /storm) to the new URL.
Answer
Try this:
server {
listen 80;
server_name firstnode.com;
location ~ ^/storm(?.*)$ {
return 301 $scheme://secondnode.com:8080$section;
}
}
Here we capture the part after /storm
into section
variable, and then use that variable in the return
statement to form the desired path.
No comments:
Post a Comment