help with replacing chars "_" to "." in a $variable

andres-m77 nginx-forum at nginx.us
Fri Jan 13 13:44:13 UTC 2012


I would appreciate your help

I have to do the following request

http://subdomain_domain_extension_tdl.domain.com/

Where .domain.com must be deleted and subdomain_domain_extension_tdl
must be converted to subdomain.domain.extension.tdl


I did this:

        set $subdomain "";

        if ($host ~* "^(.+)\.domain\.com$") {
            set $subdomain $1;
            break;
        }

          resolver 8.8.8.8;
          proxy_pass        http://$subdomain;
          proxy_set_header  X-Real-IP  $remote_addr;


Then i get $subdomain as: subdomain_domain_extension_tdl but i need to
transform it into subdomain.domain.extension.tdl

Could you please help me determining how could i do this? i would like
to serve as proxy in this way:


If you want to get inside any blocked website like www.facebook.com be
able to do it throug www_facebook_com.domain.com

Also i know that perhaps sometimes subdomain_domain_extension_tdl could
be domain_extension_tdl, 


Thanks in advance!
Andrés

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,221176,221176#msg-221176



More information about the nginx mailing list