searxng-docker icon indicating copy to clipboard operation
searxng-docker copied to clipboard

Changing server port cannot be done via settings.yaml

Open schklom opened this issue 3 years ago • 10 comments

Setting

server:
  port: 1234

in settings.yaml does not make the Docker container listen on 0.0.0.0:1234.

Only setting

    environment:
      BIND_ADDRESS: 0.0.0.0:1234

in docker-compose.yaml makes it work.

settings.yaml is not taken into account for the port, but there is a workaround. Does setting the settings.yaml port number do anything?

EDIT: I found the workaround by looking at the entrypoint script of the Dockerfile https://github.com/searxng/searxng/blob/31521f3a465fa2beb7e3fd7ed47621262a28f554/dockerfiles/docker-entrypoint.sh#L26-L27:

export DEFAULT_BIND_ADDRESS="0.0.0.0:8080"
export BIND_ADDRESS="${BIND_ADDRESS:-${DEFAULT_BIND_ADDRESS}}"

schklom avatar May 01 '22 04:05 schklom

I can confirm this issue still persist as of now.

l2evy avatar May 06 '22 09:05 l2evy

I'm sorry for the delay.

If you talk about the Caddy image, just change Caddy configuration since the network is the one from the host: https://github.com/searxng/searxng-docker/blob/ba1569dafb1c7737f3b18f86a4ab0e6ceb14f8fc/docker-compose.yaml#L8

If you talk about the SearXNG image, change this line: https://github.com/searxng/searxng-docker/blob/ba1569dafb1c7737f3b18f86a4ab0e6ceb14f8fc/docker-compose.yaml#L43

dalf avatar May 17 '22 06:05 dalf

@dalf I was talking about the SearXNG image. Changing https://github.com/searxng/searxng-docker/blob/ba1569dafb1c7737f3b18f86a4ab0e6ceb14f8fc/docker-compose.yaml#L43 only maps ports, it doesn't make the image communicate via a port other than 8080.

I mean that I can use

 - "127.0.0.1:8080:9999" 

but the inner port that the container sends data through remains 8080 despite the outer port 9999 being exposed. The outer port 9999 will not transfer data on its own.

A possible fix would be to amend https://github.com/searxng/searxng/blob/f814ac703b25640d28ab3a4a096f693808cde6db/dockerfiles/docker-entrypoint.sh#L26

export DEFAULT_BIND_ADDRESS="0.0.0.0:8080"
export BIND_ADDRESS="${BIND_ADDRESS:-${DEFAULT_BIND_ADDRESS}}"

into

export DEFAULT_BIND_ADDRESS="0.0.0.0:${BIND_PORT:-8080}"
export BIND_ADDRESS="${BIND_ADDRESS:-${DEFAULT_BIND_ADDRESS}}"

and pass BIND_PORT as a Docker environment variable. However, I have no idea how settings.yaml is handled.

schklom avatar May 17 '22 22:05 schklom

I don't understand the use case: since you can change the port mapping, when you do need to change the listening port inside the docker image?

dalf avatar May 18 '22 05:05 dalf

I pass this container's network via a vpn container. The vpn container then exposes ports to my local network. Another container (passed through the vpn container) uses internal port 8080 and cannot be changed. SearXNG and that other container cannot coexist.

In case I am not clear, this is the port setup I would like but cannot achieve

services:
  vpn:
    ports:
      - 8080:8080 # Libreddit
      - 8081:8080 # SearXNG
  
  searxng:
    network_mode: service:vpn

Libreddit forces port 8080. SearXNG as well unless I use an undocumented environment variable (c.f. first post).

This is not a major issue and I provided a hacky solution. The problem is that the documentation in settings.yaml is wrong, and I wanted to show away to do it, in case anyone else has the same issue.

schklom avatar May 18 '22 20:05 schklom

I could see that caddy was drying without any error when I tried shaping the port binding too !!

cochunni avatar Aug 23 '22 07:08 cochunni

I have mine on a dedicated IP, on Unraid via a MACVLAN and cannot hit the server on port 80. It's hard-coded to port 8080. This is nuts.

quadcom avatar May 09 '23 01:05 quadcom