May 18, 2020
0
Level 7
Nginx variable not working
I allow my app user's to use a custom domain. So i set up a regex server name to catch the domain in a variable and serve the correct letsencrypt certificate:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name ~^(www\.)?(?<domain>.+)$;
root /home/forge/myapp.com/public;
# This works
add_header X-testvar /etc/nginx/ssl/$domain/xxxxx/server.crt;
# This makes nginx crash (domain variable)
ssl_certificate /etc/nginx/ssl/$domain/xxxxx/server.crt;
# This works (hardcoded domain)
ssl_certificate /etc/nginx/ssl/myapp.com/xxxxx/server.crt;
Edit: Just found out variables can be used in the ssl_certificate path, but they affect the performance. So, is the only option to create a new server block for every customer's domain name?
Please or to participate in this conversation.