Score:0

Nginx pass Port from URL to proxy pass

in flag

i use an nginx server. And i want to pass port data from the url to the proxy_pass. Is that possible? For example: example.de/?port=4555 or example.de/4555 With that code, i can get the subdomain part, but i cant modify this, that i can get the port.

server { 

    listen 80 default_server;

    server_name ~^(?<proj>[^.]+).example.de;
    

    location / {
        proxy_pass http://localhost:$proj;
        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;
    }
}
djdomi avatar
za flag
Does this answer your question? [nginx get server port and use it as variable](https://serverfault.com/questions/831996/nginx-get-server-port-and-use-it-as-variable)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.