Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Wildcard subdomain proxy_pass

jazz1611jazz1611 Member
edited April 2018 in Help

Hello,

I need help rewrite to proxy_pass with wildcard subdomain. I want it proxy_pass like this:

from "*.destination.com/?string" to "*.mydomain.com/?string"
ex: "a.destination.com/?string=B" to "a.mydomain.com/?string=B"

Regards,

Comments

  • lemonlemon Member
    edited April 2018
    server {
            listen 443;
            ssl on;
            ssl_certificate         /path/to/cert;
            ssl_certificate_key     /path/to/privkey;
    
            server_name             a.mydomain.com;
    
            location / {
                    proxy_pass http(s?)://a.destination.com;
            }
    }
    
  • @lemon said:
    server {
    listen 443;
    ssl on;
    ssl_certificate /path/to/cert;
    ssl_certificate_key /path/to/privkey;

    server_name a.mydomain.com;

    location / {
    proxy_pass http(s?)://a.destination.com;
    }
    }

    If more 50 subdomain of destination.com, how we do?

  • Haven't tried this, but try a regex capture:

    server_name ~(?<subdom>.+)\.destination\.com$
    ...
    proxy_pass $scheme://$subdom.mydomain.com$request_uri
    
  • @seanho said:
    Haven't tried this, but try a regex capture:

    server_name ~(?<subdom>.+)\.destination\.com$
    ...
    proxy_pass $scheme://$subdom.mydomain.com$request_uri
    

    Seem your rewrite not correct

  • FHRFHR Member, Host Rep
    edited April 2018

    server_name ~(?<sub>[^\.]*)\.destination\.com$;

    Copied straight from my server, where this regex works fine.

    proxy_pass $scheme://$sub.mydomain.com$request_uri

  • @FHR said:
    server_name ~(?<sub>[^\.]*)\.destination\.com$;

    Copied straight from my server, where this regex works fine.

    proxy_pass $scheme://$sub.mydomain.com$request_uri

    As i see it will bypass to your domain, not from destination

  • FHRFHR Member, Host Rep

    @jazz1611 said:

    @FHR said:
    server_name ~(?<sub>[^\.]*)\.destination\.com$;

    Copied straight from my server, where this regex works fine.

    proxy_pass $scheme://$sub.mydomain.com$request_uri

    As i see it will bypass to your domain, not from destination

    It will do exactly what you written in your first post.

  • jazz1611jazz1611 Member
    edited April 2018

    @FHR said:

    @jazz1611 said:

    @FHR said:
    server_name ~(?<sub>[^\.]*)\.destination\.com$;

    Copied straight from my server, where this regex works fine.

    proxy_pass $scheme://$sub.mydomain.com$request_uri

    As i see it will bypass to your domain, not from destination

    It will do exactly what you written in your first post.

    No, you are mistake my mean. I want leech content from destination to my site via proxy_pass

    Update: i just replace destination to mydomain and it work

  • FHRFHR Member, Host Rep

    @jazz1611 said:

    @FHR said:

    @jazz1611 said:

    @FHR said:
    server_name ~(?<sub>[^\.]*)\.destination\.com$;

    Copied straight from my server, where this regex works fine.

    proxy_pass $scheme://$sub.mydomain.com$request_uri

    As i see it will bypass to your domain, not from destination

    It will do exactly what you written in your first post.

    No, you are mistake my mean. I want leech content from destination to my site via proxy_pass

    By leech, do you mean redirect visitors of a page you don't have control over to your server? If so, it doesn't work like this.

  • @FHR said:

    @jazz1611 said:

    @FHR said:

    @jazz1611 said:

    @FHR said:
    server_name ~(?<sub>[^\.]*)\.destination\.com$;

    Copied straight from my server, where this regex works fine.

    proxy_pass $scheme://$sub.mydomain.com$request_uri

    As i see it will bypass to your domain, not from destination

    It will do exactly what you written in your first post.

    No, you are mistake my mean. I want leech content from destination to my site via proxy_pass

    By leech, do you mean redirect visitors of a page you don't have control over to your server? If so, it doesn't work like this.

    I just replace destination to mydomain and it work :)

Sign In or Register to comment.