documentation
documentation copied to clipboard
[Bug]: Nginx config in subfolder split is invalid
Link to the documentation page or resource
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/optional-software/nginx-proxy.html#nginx-virtual-host
Describe the bug
The settings for NGINX subfolder split are incorrect. Nginx doesn't allow same location used twice.
` ...
Static Root
location / {
root /var/www/html;
}
# Proxy Config
location / {
... `
The documentation in version 3.x states:
` server { # Listen HTTP listen 80; server_name example.com;
# Redirect HTTP to HTTPS
return 301 https://$host$request_uri;
}
server { # Listen HTTPS listen 443 ssl; server_name example.com;
# SSL config
ssl_certificate /path/to/your/certificate/file;
ssl_certificate_key /path/to/your/certificate/key;
# Static Root
location / {
root /var/www/html;
}
# Strapi API
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://strapi;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass_request_headers on;
}
# Strapi Dashboard
location /dashboard {
proxy_pass http://strapi/dashboard;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass_request_headers on;
}
} `
Additional context
No response
Suggested improvements or fixes
Update example for NGINX on v4 documentation.
Related issue(s)/PR(s)
No response
Yup your right, I completely missed this while I was writing it
Thank you for reporting this and apologies it took so long to get an answer from the Strapi documentation team. @derrickmehaffy Do you know how we could update the Nginx proxy docs or should I discuss this with some other engineers?
We removed this example completely as it's honestly not recommend. It got removed quite a while ago.
@derrickmehaffy, what is the recommendation the for using with NGINX?
One of the other two examples in the current documentation. Ideally using a subdomain is highly advised.
I'm gonna go ahead and close this one as we do not plan to readd this documentation as we do not support sub-folder splitting, it's not just a bad practice with Strapi but anti-pattern in general.