Score:0

How can I create an nginx reverse proxy that passes through all traffic for all domains?

cn flag

I want to make it possible to pass all traffic regardless of hostname or domain through the nginx server.

I either want to be able to do something like this: http://mynginx/domain.I.want.somehost/url/params/this/host. And then have nginx forward the request to http://domain.I.want.somehost/url/params/this/host.

Or make it possible to hit the server and specify a host header. So a request to http://mynginx/url/params/this/host with HOST header set to domain.I.want.somehost would forward traffic to http://domain.I.want.somehost/url/params/this/host.

I'm having a hard time finding examples of how to do this.

Before doing any URL rewriting I tried to just pass all traffic through like this:

server {
     listen  80 default_server;
     listen  443 default_server;

        location / {
           proxy_pass https://$http_host;
           proxy_set_header Host $http_host;
        }

}

When I run curl --header 'Host: api.ipify.org' 127.0.0.1 I get a 502 bad gateway error.

This endpoint is accessible though: curl 'https://api.ipify.org?format=json'

djdomi avatar
za flag
you need to specify the target as a native ip and send the domain as a extra Header usually
cn flag
Are there any examples of a complete configuration that does what I'm trying to do? I could not find any examples for proxying all traffic and making it possible to dynamically specify the downstream host.
JoelCrypto avatar
th flag
`proxy_pass $scheme://$host$request_uri`
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.