Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing server port cannot be done via settings.yaml #20

Closed
schklom opened this issue May 1, 2022 · 13 comments · Fixed by #285
Closed

Changing server port cannot be done via settings.yaml #20

schklom opened this issue May 1, 2022 · 13 comments · Fixed by #285
Labels

Comments

@schklom
Copy link

schklom commented May 1, 2022

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}}"
@l2evy
Copy link

l2evy commented May 6, 2022

I can confirm this issue still persist as of now.

@dalf
Copy link
Member

dalf commented May 17, 2022

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:

network_mode: host

If you talk about the SearXNG image, change this line:

- "127.0.0.1:8080:8080"

@schklom
Copy link
Author

schklom commented May 17, 2022

@dalf I was talking about the SearXNG image.
Changing

- "127.0.0.1:8080:8080"

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.

@dalf
Copy link
Member

dalf commented May 18, 2022

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?

@schklom
Copy link
Author

schklom commented May 18, 2022

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.

@cochunni
Copy link

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

@quadcom
Copy link

quadcom commented May 9, 2023

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.

@epd5
Copy link

epd5 commented Jul 18, 2024

This is still present. Playing around with it the only thing that worked was in Docker Compose placing:

      environment:
           - BIND_ADDRESS=0.0.0.0:8888

Any variation in the settings.yaml had no effect on the bound port (default 8080).

@lmaddox
Copy link

lmaddox commented Jul 26, 2024

This is still present. Playing around with it the only thing that worked was in Docker Compose placing:

      environment:
           - BIND_ADDRESS=0.0.0.0:8888

Any variation in the settings.yaml had no effect on the bound port (default 8080).

thank you for this. I'm one step closer now.

@garagetrader
Copy link

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.

I'm here for this exact same issue with the same 2 containers. Thanks for working on this ahead of me.

@Bnyro
Copy link
Member

Bnyro commented Oct 4, 2024

The intended way to set the port when using Docker is to use the BIND_ADDRESS environment variable, the searxng-docker documentation just lacks information on how to self-host without Caddy so far. Documentation on that will be added with #285.

@Bnyro Bnyro closed this as completed in #285 Oct 6, 2024
@schklom
Copy link
Author

schklom commented Oct 6, 2024

@Bnyro Shouldn't https://github.com/searxng/searxng/blob/master/searx/settings.yml be updated as well by removing the port line on

https://github.com/searxng/searxng/blob/5332d3a0b8f94a7a984d22cbcfa1fb9c34cb3ff9/searx/settings.yml#L77-L79

server:
  # Is overwritten by ${SEARXNG_PORT} and ${SEARXNG_BIND_ADDRESS}
  port: 8888

?

@Bnyro
Copy link
Member

Bnyro commented Oct 6, 2024

No, it's used by non-docker-deployments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

10 participants