What do you need help with?
Hey, I am running my Apostrophe CMS project (https://github.com/vincentrohde/bachelor) with Docker + a reverse NGINX proxy to serve it on a route /bachelor
. It’s basically a multi-project server, where the projects are available on different routes.
It works good so far, besides the fact that all asset HTTP requests are static and go to the root of the url. Is there a way to make the calls dynamic? Right now they look like this:
Example
This is the src:
/modules/apostrophe-ui/js/context.js
which results in this request (404)
http://localhost/modules/apostrophe-ui/js/context.js
The request should look like this:
This src
./modules/apostrophe-ui/js/context.js
which results in this request
http://localhost/bachelor/modules/apostrophe-ui/js/context.js
Here the request will result in a 200, correct file.
docker-compose.yml
version: '3.7'
services:
# Proxies requests to internal services
nginx-server:
image: nginx:1.17.10
container_name: nginx-server
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- '80:80'
mongo:
image: 'mongo:latest'
volumes:
- './data/db:/data/db'
restart: always
bachelor:
build: ./bachelor
volumes:
- './bachelor/data:/app/data'
- './bachelor/public/uploads:/app/public/uploads:rw'
links:
- mongo:mongo
depends_on:
- mongo
environment:
APOS_MONGODB_URI: 'mongodb://mongo:27017/db'
APOS_ALWAYS_COPY_ASSETS: '1'
nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost 127.0.0.1;
location /bachelor/ {
proxy_pass http://bachelor:3000/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_intercept_errors on;
}
}
}
What have you already tried?
I have tried to set the baseUrl: http://localhost/bachelor/
in my app.js file when passing the config to Apostrophe. It doesn’t work. I am not sure if I understood the baseUrl
property correctly?
What do you have?
My version of the apostrophe
module is: ^2.110.0
My version of node
is (node --version
): 12
My operating system is: Docker