Nginx – Apache Guacamole + Nginx Proxy Manager = SyntaxError

nginxreverse-proxy

I'm running Apache Guacamole inside Docker and I want to make it publicly accessible using Nginx Proxy Manager.

This is the Docker Stack for Guacamole:

version: "3"

volumes:
  mysql:
    driver: local

services:
  guacamole:
    image: guacamole/guacamole:latest
    container_name: guacamole_server
    restart: always
    ports:
      - 8080:8080
    depends_on:
      - mysql
      - guacd
    environment:
      - MYSQL_HOSTNAME=mysql
      - MYSQL_PORT=3306
      - MYSQL_DATABASE=guacamole
      - MYSQL_USER=guacamole
      - MYSQL_PASSWORD=secret
      - GUACD_HOSTNAME=guacd
      - GUACD_PORT=4822

  mysql:
    image: mysql:latest
    container_name: guacamole_mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=guacamole
      - MYSQL_USER=guacamole
      - MYSQL_PASSWORD=secret
      - MYSQL_DATABASE=guacamole
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=guacamole"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - mysql:/var/lib/mysql

  guacd:
    image: guacamole/guacd:latest
    container_name: guacamole_guacd
    restart: always

When I access Guacamole via it's local IP on port 8080 everything works perfectly fine.

Then I added a new Proxy Host to Nginx Proxy Manager with the following configuration:

Details:

  • Domain Name: (something)
  • Scheme: http
  • IP: 192.168.123.123
  • Port: 8080
  • Cache Assets: disabled
  • Block Common Exploits: enabled
  • Websockets Support: enabled
  • Access List: Publicly Accessible

SSL:

  • Force SSL: enabled
  • HSTS Enabled: enabled
  • HTTP/2 Support: enabled
  • HSTS Subdomains: disabled

Custom Locations:

  • (none)

Advanced:

  • (nothing)

So far it still works perfectly fine.

If I now change the configuration:
(Grabbed that from https://github.com/jc21/nginx-proxy-manager/issues/104)

Custom Locations:

  • Location: /
  • Scheme: http
  • Forward Hostname: 192.168.123.123/guacamole/
  • Port: 8080
  • Advanced: (nothing)

Then I get a blank page, but all the source code gets loaded and all requests are status 200.
In the console of the browser I see:

Uncaught SyntaxError: expected expression, got '<'

The exact same happens when I instead of the 'Custom Locations' configuration I make my own advanced configuration:

location / {
    proxy_pass $forward_scheme://$server:$port/guacamole/;
}

I also tried different configurations here, but I always got that error. I didn't find any hint in a long online research.

Best Answer

Use no 'Custom Location'.

Put this in Advanced:

location / {
    proxy_pass http://192.168.123.123:8080/guacamole/;
    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_cookie_path /guacamole/ /;
    access_log off;
}
Related Topic