I have been trying to get nginx to reverse proxy gacamole, but was not very successful. For this, over the past days, I have been following several howto's describing how to install nginx, guacamole and configure nginx to proxy the Tomcat 8080 port. I have the feeling I'm almost there, but simply can't make the last step...
On an Ubuntu 22.04.05 LTS machine, I installed nginx and Tomcat9 out of the box. Next, I deleted the /etc/nginx/sites-available/default file, and removed the symlink to that file in /etc/nginx/sites-enabled, and restarted nginx.
Then I installed guacamole (1.55, guacd and the webapp in tomcat). After having done this, I can get to the webapp from another machine using http://nginx-handbook.test:8080/guacamole. So, guacamole works.
Now for the proxying bit: I created a file guacamole.conf in /etc/nginx/conf.d with the following content :
server {
listen 80;
server_name nginx-handbook.test;
access_log /var/log/nginx/guac_access.log;
error_log /var/log/nginx/guac_error.log;
location = / {
proxy_pass http://127.0.0.1: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;
client_max_body_size 1g;
access_log off;
}
}
Restarted nginx, and tried to go to guacamole from another server using http://nginx-handbook.test/ , but I'm getting a 404.
I know the proxy does work (sort of), because my actions are being logged in the proxy logs :
(guac_access.log)
192.168.56.1 - - [11/Sep/2024:16:07:38 +0000] "GET /guacamole/ HTTP/1.1" 404 197 "-"
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/128.0.0.0 Safari/537.36"
192.168.56.1 - - [11/Sep/2024:16:07:40 +0000] "GET /guacamole/ HTTP/1.1" 404 197 "-"
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/128.0.0.0 Safari/537.36"
(guac_error.log)
2024/09/11 16:07:38 [error] 29619#29619: *1
"/usr/share/nginx/html/guacamole/index.html" is not found (2: No such file or
directory), client: 192.168.56.1, server: nginx-handbook.test, request: "GET
/guacamole/ HTTP/1.1", host: "nginx-handbook.test"
2024/09/11 16:07:40 [error] 29619#29619: *1
"/usr/share/nginx/html/guacamole/index.html" is not found (2: No such file or
directory), client: 192.168.56.1, server: nginx-handbook.test, request: "GET
/guacamole/ HTTP/1.1", host: "nginx-handbook.test"
Although the error is quite clear (nginx is looking for guacamole in /usr/share/nginx/html), I don't quite understand. Was expecting to redirect to port 8080, and let Tomcat do the rest.
The /usr/share/nginx/html root is not set in any of the other nginx config files.
Should I set the root directive to point to /var/lib/tomcat/webapps ? That was not documented anywhere in the howto's I've seen.
Any help would be greatly appreciated.