Nginx proxy pass for alias does not load font files

I try to set a page in WordPress as a standalone subdomain site by alias. I found below link from stack and it indeed works for me for sub-domain reassignment How to Alias a Page to a Sub-Domain Below is my setting. server { listen 443 ssl; server_name abc.example.com; location / { proxy_pass https://127.0.0.1/abc$request_uri; proxy_set_header Host example.com; } } But, on the proxied subdomain, I cannot load font files properly. I've tried both local font files and Google remote font, but neither of them works. I guess there is an issue with proxt header and firewall that disallows to call the font file when the domain name changes. I've tried with simple html coded webpage w/ local font files, which indeed loaded font properly. I believe it is somehow connected to WordPress's security setting, or insufficient proxy header setting that I don't know much of. I've also tried location in the same server block, but font files are not loaded. NGINX Proxy Pass server { listen 443 ssl; server_name example.com; root /var/www/websites/example; location ^~ /abc/ { proxy_pass https://abc.example.com; proxy_set_header Host example.com; } }

Comment (1)

Jese Leos

August 19, 2024

Verified user

Added below definition for font files in the same server block. Problem solved. location ~* \.(eot|ttf|woff|woff2|otf)$ { try_files $uri =404; expires 1M; add_header Cache-Control "public"; add_header Access-Control-Allow-Origin *; }

You’ll be in good company