79613864

Date: 2025-05-09 09:53:47
Score: 1
Natty:
Report link

https://github.com/jlesage/docker-baseimage-gui/issues/160#issuecomment-2862376646

Your requirements similar like this?

From

https://github.com/oneclickvirt/dockerfile-templates/tree/main/idea

and

https://github.com/jlesage/docker-crashplan-pro?tab=readme-ov-file#routing-based-on-url-path

I want to use a custom path for reverse proxy access to a container based on the jlesage/baseimage-gui:ubuntu-22.04-v4 base image, instead of using the default root path /

Create a custom network named web-net to enable communication between containers:

docker network create web-net

Start the IDEA container without exposing any ports, connect it to the web-net network (the container's web port is set to 31000 at the Dockerfile stage):

docker run -d \
  --name idea \
  --network web-net \
  jetbrains-idea-plug-cuda:v2024.2.5

Create a file named default.conf in the current directory with the following content:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

upstream idea_app {
    # Use the reachable container name for reverse proxy
    server idea:31000;
}

server {
    listen       80;
    server_name  _;

    location = /ide {
        return 301 $scheme://$http_host/ide/;
    }

    location /ide/ {
        rewrite ^/ide(/.*)$ $1 break;

        proxy_pass http://idea_app/;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 86400;
    }
}

Create a file named Dockerfile in the current directory with the following content:

FROM nginx:alpine

COPY default.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

Build the custom NGINX image and run the container, connect it to the web-net network, and map port 80 of the container to port 31000 on the host:

docker build -t custom-nginx-proxy .
docker run -d \
  --name nginx-proxy \
  --network web-net \
  -p 0.0.0.0:31000:80 \
  custom-nginx-proxy

Now can access the service via http://<host-ip>:31000/ide/

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: spiritlhl