Quantcast
Channel: myVesta
Viewing all articles
Browse latest Browse all 266

General discussion • Re: Nginx get domainname without TLD or suffix

$
0
0
hi. any update on this.
i hope many developers will be looking for similar solution for SaSS product hosted on single domain and served to individual users by subdomains, and when end user requires custom domain to show content from a sub-domain this workaround is required.

based on some solutions i tried below steps.

1.
add map function on /etc/nginx/nginx.conf inside http block
Screenshot 2023-12-31 012342.png

Code:

map $domain $domain_without_tld {    ~^(?<domain_name>[^.]+)\..+$ $domain_name;}
when i do this, i get $domain undefined variable error. without $ symbol, there is no error, but again it doesnt seems to be working.

2.
added proxy pass on forcessl.tpl file at /usr/local/vesta/data/templates/web/nginx/force-https.stpl
Screenshot 2023-12-31 013023.png

Code:

location / {        proxy_pass      https://%ip%:%web_ssl_port%;        proxy_set_header Host $domain_without_tld.%domain_idn%;        location ~* ^.+\.(%proxy_extentions%)$ {            root           %sdocroot%;            access_log     /var/log/%web_system%/domains/%domain%.log combined;            access_log     /var/log/%web_system%/domains/%domain%.bytes bytes;            expires        max;            # try_files      $uri @fallback;        }    }
I need to use map function to get value of domain withoud tld on tpl file.
can you please help me with a solution for this?

Statistics: Posted by sparkzara — Sat Dec 30, 2023 9:04 pm



Viewing all articles
Browse latest Browse all 266

Trending Articles