I am trying to deploy a phpBB forum behind a load balancer that will distribute the traffic:
- If
https://example.com/forum/*
, redirect to instance A (phpbb + nginx) - Any other path on
https://example.com/
, redirect to instance B (other stuff)
Therefore, I want to have phpBB installed on instance A and available under https://example.com/forum/
.
On instance A, I am running nginx. Here's my nginx.config (with the important stuff only):
http {
server {
listen [::]:443 http2 ssl default_server;
listen 443 http2 ssl default_server;
server_name example.com;
# PHP BB
root /var/www/mysite/forum/src;
# fastcgi
include /etc/nginx/conf.d/fastcgi-php.conf;
location /forum {
index index.php index.html index.htm;
rewrite ^/forum/(.*) /$1 break;
try_files $uri $uri/ @rewrite_app;
}
location ~ \.php(/|$) {
try_files $uri $uri/ /app.php$is_args$args;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
}
location @rewrite_app {
rewrite ^(.*)$ /app.php/$1 last;
}
}
}
Here are my problems:
- When I visit
https://example.com/forum/
the forum loads but all internal links are written without the/forum/
path, making the load balancer redirect to instance B. - When I visit
https://example.com/forum/index.php
, internal links are written correctly with the/forum/
path, but I get a phpBB application 404The page is not found
.
What am I doing wrong ?