Why does Code-server not work when I enable forwarding in NGINX?

I am uploading a stack with the following compose:

services: 
  code-server:
    container_name: code-server
    hostname: CodeServer
    image: lscr.io/linuxserver/code-server:latest
    
    volumes:
      #bind -compartilhado
      - ${HOME_PATH}/Documentos/Repositorio/stacks/ansible/ansible/ansible_cw5:/config/workspace/ansible_cw5
      - code-server-data:/data
    
    networks:
      nginx-local:
        ipv4_address: 10.120.4.3
    
    ports:
      - 8081:8443 #mapear portas no NGINX

    #sera reiniciado auto a menos que seja parado manualmente
    restart: unless-stopped
    
    depends_on:
      - ansible

    environment:
      - PUID=1000
      - PGID=1000
      - PASSWORD=${PASS} #para GUI
      - SUDO_PASSWORD=${ROOT_PASS} #senha de privilegio
      - PROXY_DOMAIN=${DOMAIN} #criar nome no DNS
      - DEFAULT_WORKSPACE=/config/workspace #diretorio de workspace
      - TZ=${TZ}


  ansible:
    container_name: ansible-v4
    hostname: Ansible

    image: ansible:v2
    
    volumes:
      #bind - compartilhado
      - ${HOME_PATH}/Documentos/Repositorio/stacks/ansible/ansible/ansible_cw5:/ansible/ansible_cw5:ro
    
    working_dir: /ansible/ansible_cw5

    networks:
      ansible-local:
        ipv4_address: 10.120.6.2
    environment:
      - TZ=America/Campo_Grande

    #container será sempre reiniciando sempre que parar
    restart: always
    stdin_open: true   
    tty: true 
    command: bash

  nginx_manager:
    container_name: nginx-proxy
    hostname: NGINX
    image: "jc21/nginx-proxy-manager:latest"

    volumes:
      - nginx-data:/data
      - nginx-letsencrypt:/etc/letsencrypt  # Volume necessário para certificados SSL/TLS

    networks:
      nginx-local:
        ipv4_address: 10.120.4.2

    ports:
      - 80:80 
      - 443:443 
      - 81:81 #gerencia NGINX

    restart: unless-stopped

    depends_on:
      - code-server

    environment:
      - INITIAL_ADMIN_EMAIL=${INITIAL_ADMIN_EMAIL}
      - INITIAL_ADMIN_PASSWORD=${INITIAL_ADMIN_PASSWORD}
  


#cria volumes persistentes
volumes:
  nginx-data:
  nginx-letsencrypt:
  code-server-data:



networks:
  nginx-local:
    driver: bridge
    ipam: 
      config:
        - subnet: 10.120.4.0/23
          ip_range: 10.120.4.0/24 
          gateway: 10.120.4.1

  ansible-local:
    driver: bridge
    ipam: 
      config:
        - subnet: 10.120.6.0/23
          ip_range: 10.120.6.0/24
          gateway: 10.120.6.1

The idea is for Ansible to be accessible via the code-server, allowing configuration files to be edited through it, and for the code-server to be accessible via a local domain already set in the /etc/hosts file to resolve to the Nginx address (10.120.4.2).

The problem is that when I access the domain in the browser, the login screen loads, but after logging in, a completely blank screen is displayed, and the URL changes to http://code-server.gabriel/?folder=/config/workspace.

However, if I access the code-server using localhost:8081, I can access it normally without any issues. This seems to be some incorrect configuration in NGINX, but I haven’t been able to figure out exactly what it could be.

I’m using NGINX Proxy Manager, and here’s the only configuration I made for the host redirection:

Domain Names: code-server.gabriel Scheme: http Forward Hostname / IP: 10.120.4.3 Forward Port: 8443

Upvotes: 0

Views: 41

Answers (0)

Related Questions