Reverse proxy with location

I want to run Squidex on a URL like this http://server.com/squidex. I’m using docker for configure squidex and nginx for proxy.

In the proxy have:
location /squidex/ {

    proxy_pass          http://squidex/;
    proxy_redirect http://server.com/squidex/ http://squidex/;

    proxy_set_header    Host               $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-Host   $host;
    proxy_set_header    X-Forwarded-Server $host;
    proxy_set_header    X-Forwarded-Port   $server_port;
    proxy_set_header    X-Forwarded-Proto  $scheme;
    
}

In docker-compose have:

  • SQUIDEX_DOMAIN =server.com
  • SQUIDEX_PROTOCOL = http
  • URLS__BASEURL=http://server.com/squidex/
  • URLS__ENFORCEHTTPS=false

The result is:
URL: http://server.com/identity-server/setup
404 Not found

Excepted: URL: http://server.com/squidex/identity-server/setup

Can you Help me? Please

Environment

  • [x ] Self hosted with docker

Version: image: squidex/squidex:latest

I though this has been fixed: [SOLVED] Hosting squidex on a subpath

But I am not 100% sure, because I have not received any feedback. Is the problem the redirect or what happens when you access: http://server.com/squidex/identity-server/setup

I just tested it again and it work as expected with my setup.I have used IIS, but it should not really matter.

Perhaps you can provide me your full docker-compose setup including nginx?

Here is a docker compose example:

version: "3.5"

services:
  squidex_mongo:
    image: mongo:latest
    container_name: squidex_database
    volumes:
      - sq_mongo_data:/data/db
    restart: unless-stopped

  squidex:
    image: squidex/squidex:latest
    container_name: squidex_app
    environment:
      SQUIDEX_DOMAIN: ${DOMAIN}
      SQUIDEX_PROTOCOL: http
      urls:basePath: "/squidex"
      URLS__BASEURL: http://${DOMAIN}
      URLS__ENFORCEHTTPS: ${SQUIDEX_FORCE_HTTPS}
      EVENTSTORE__MONGODB__CONFIGURATION: mongodb://squidex_mongo
      STORE__MONGODB__CONFIGURATION: mongodb://squidex_mongo
      IDENTITY__ADMINEMAIL: ${SQUIDEX_ADMINEMAIL}
      IDENTITY__ADMINPASSWORD: ${SQUIDEX_ADMINPASSWORD}
      IDENTITY__GOOGLECLIENT: ${SQUIDEX_GOOGLECLIENT}
      IDENTITY__GOOGLESECRET: ${SQUIDEX_GOOGLESECRET}
      IDENTITY__GITHUBCLIENT: ${SQUIDEX_GITHUBCLIENT}
      IDENTITY__GITHUBSECRET: ${SQUIDEX_GITHUBSECRET}
      IDENTITY__MICROSOFTCLIENT: ${SQUIDEX_MICROSOFTCLIENT}
      IDENTITY__MICROSOFTSECRET: ${SQUIDEX_MICROSOFTSECRET}
    depends_on:
      - squidex_mongo
    volumes:
      - squidex_assets:/app/Assets
    restart: unless-stopped
volumes:
  sq_mongo_data:
  squidex_assets:

I set urls:basePath: “/squidex”, like you say but thi not works… You can test?

URLS base path is not needed. Just ensure that URLS__BASEURL includes the path. In your docker-compose file it does not look like this.

Have you tried:

URLS__BASEURL: http://${DOMAIN}/squidex

I also need a full reproducible example including nginx.

Yes, I have the same error! with http://server.com/squidex … And you?

As I said: It works for me with IIS. But I would like to have a full example with nginx that I can just run.

Clone this git: Is ready to use

I can reproduce it and have tested it locally:

What you need to do is the following:

  1. Change your nginx config to this:
server {
    listen   80;
    listen   [::]:80;
    server_name  host.docker.internal;

    location /squidex {
        proxy_pass          http://squidex/squidex;

        proxy_set_header    Host               $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-Host   $host;
        proxy_set_header    X-Forwarded-Server $host;
        proxy_set_header    X-Forwarded-Port   $server_port;
        proxy_set_header    X-Forwarded-Proto  $scheme;
        
    }
}

And use thefollowing environment variables for Squidex:

      URLS__BASEPATH: "/squidex"
      URLS__BASEURL: http://${SERVER_NAME}/squidex/

Please not that you also need https to run Squidex.

1 Like

OK my mistake it’s a problem in volumes! Can close! Thanks for your help!

1 Like