NGINX Wildcard Subdomain Proxy Config

nginx Mar 04, 2020

If you want to run an already existing multitenant service behind Nginx


A Nginx Configuration is required as follows


upstream destination {
    server otherdomain.com:80 weight=50 fail_timeout=30s;
}

server {
    listen 80;
    server_name ~^(?<subdomain>.+)\.mydomain\.com$;

    location / {
        proxy_pass http://destination;
        proxy_set_header Host $subdomain.otherdomain.com;
    }
}
nginx.conf

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.