Nginx proxy_pass from * to *

You can try this one:

map $host $non_local_host {
    ~^(.*\.)?local\.domain\.com    "${1}";

server {
    listen 80;
    listen [::]:443 ssl;
    listen 443 ssl;
    # ssl config here


    location / {
        proxy_pass $scheme://;
        proxy_set_header Host $non_local_host;
        proxy_redirect http://$non_local_host/ http://$host/;
        proxy_redirect https://$non_local_host/ https://$host/;

The server name will match 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.

Leave a Comment

Your email address will not be published.

Scroll to Top