I would like to direct multiple (but specific) subdomains in a single server block to a path of the same name, using proxy_pass:
api.example.com to www.example.com/api webhook.example.com to www.example.com/webhook iframe.example.com to www.example.com.webook
This directs all requests from api
, webhook
, and iframe
to /api
, but I would like to direct api
to /api
, webhook
to /webhook
etc.
server {
listen 443 ssl http2;
#tls/ssl certificates
ssl_certificate /etc/ssl/example.crt;
ssl_certificate_key /etc/ssl/example.key;
#specify subdomains
server_name api.example.com webhook.example.com iframe.example.com;
#reverse proxy to localhost
location / {
proxy_pass https://127.0.0.1/api$request_uri;
proxy_set_header Host "www.example.com";
}
}
Is it possible to specify the primary directory as a function of the subdomain, or does this need to be three separate server blocks?
0 Answers