System Information
- Strapi Version: 3.6.8
- Operating System: Ubuntu 20.04
- Database: MySQL 8
- Node Version: v14.18.2
- NPM Version: 6.14.15
- Yarn Version: 1.22.15
Hello,
I’m trying to host several strapi apps on a same server and domain, using Nginx with subfolder unified conf, to have something like this :
strapi.mydomain.com/blue/admin
strapi.mydomain.com/red/admin
So far I did this : 2 nginx configs, which are in sites-availables
with symlink in sites-enables
They both have the same config, unless for the upstream and location, where I change the name and/or the port.
What is strange here is if I remove one of the conf from sites-enabled
both of websites are working independently, but when I have the 2 conf enabled, then one of them get 403 forbidden
.
Here is my Nginx conf for my first site:
# path: /etc/nginx/sites-available/strapi_blue.conf
# Strapi server
upstream strapi_blue {
server 127.0.0.1:1337;
}
server {
# Listen HTTP
listen 80;
server_name strapi.mydomain.com;
# Redirect HTTP to HTTPS
return 301 https://$host$request_uri;
}
server {
# Listen HTTPS
listen 443 ssl;
server_name strapi.mydomain.com;
# SSL config
ssl_certificate /etc/letsencrypt/live/strapi.mydomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/strapi.mydomain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# Static Root
location / {
root /var/www/strapi;
}
# Strapi API and Admin
location /blue/ {
rewrite ^/blue/?(.*)$ /$1 break;
proxy_pass http://strapi_blue/;
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;
}
}
For the 2nd site, the conf is the same with those differences :
# Server
upstream strapi_red {
server 127.0.0.1:2160;
}
# API and Admin
location /red/ {
rewrite ^/red/?(.*)$ /$1 break;
proxy_pass http://strapi_red/;
...
}
When enabling the 2 confs, I got red working fine, but blue giving a 403 forbidden
with the following error in nginx logs : directory index of "/var/www/strapi/blue/" is forbidden
. (Checked permissions, they are ok)
When enabling only 1 of the confs, the corresponding site is well served and running fine.
Any clue ?