You can try this one:
map $host $non_local_host {
~^(.*\.)?local\.domain\.com "${1}domain.com";
}
server {
listen 80;
listen [::]:443 ssl;
listen 443 ssl;
# ssl config here
server_name .local.domain.com;
location / {
proxy_pass $scheme://127.0.0.1/;
proxy_set_header Host $non_local_host;
proxy_redirect http://$non_local_host/ http://$host/;
proxy_redirect https://$non_local_host/ https://$host/;
}
}
The .local.domain.com
server name will match local.domain.com
and any of it’s subdomains.
If your site make use of cookies, you may also need a proxy_cookie_domain
directive:
proxy_cookie_domain $non_local_host $host;
CLICK HERE to find out more related problems solutions.