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

URL configuration with environment variable doesn't work reliably #1525

Open
maconfr opened this issue Jul 4, 2024 · 3 comments
Open

URL configuration with environment variable doesn't work reliably #1525

maconfr opened this issue Jul 4, 2024 · 3 comments

Comments

@maconfr
Copy link

maconfr commented Jul 4, 2024

I'm using the container image to start the smtp4dev server.
I don't want to use privileged ports, even within the container, so i changed the ports for alll services.
I'm using environment Variables to configure the ports, which works well for the SMTP and IMAP port, but not for the HTTP port.

Most of the time, the server starts with the default HTTP port 80.
Console Output:

[...]
Overriding HTTP_PORTS '80' and HTTPS_PORTS ''. Binding to values defined by URLS instead 'http://*:80'.
Now listening on: http://[::]:80

Sometimes it actually starts with the configured port 5000.
Console Output:

[...]
Overriding HTTP_PORTS '80' and HTTPS_PORTS ''. Binding to values defined by URLS instead 'http://*:5000'.
Now listening on: http://[::]:5000

For some statistics i started and stopped the container 20 times with the following docker command:

docker run -it --rm \
  -p 5000:5000 \
  -p 2525:2525 \
  -e ServerOptions__Urls="http://*:5000" \
  -e ServerOptions__Port=2525 \
  -e ServerOptions__ImapPort=2143 \
  "rnwood/smtp4dev:3.6.0"

In total the HTTP Server started 12 times with port 80 and 8 times with port 5000.

This only happens when i use the ServerOptions__Urls environment variable. When i use the cli parameter --urls, it works as intended 100% of the time.
For example with this command:

clear; docker run -it --rm \
  -p 5000:5000 \
  -p 2525:2525 \
  -e ServerOptions__Port=2525 \
  -e ServerOptions__ImapPort=2143 \
  "rnwood/smtp4dev:3.6.0" \
    --urls "http://*:5000"

[...]
Overriding HTTP_PORTS '80' and HTTPS_PORTS ''. Binding to values defined by URLS instead 'http://*:5000'.
Now listening on: http://[::]:5000
@jainal09
Copy link

jainal09 commented Jul 5, 2024

+1 can confirm this issue occurs in 3.6.1 even though env ServerOptions__Urls=http://*:5001 is added in my case, 5-6/ 10 times it starts on port 80

@leomylonas
Copy link

I found that when running the (Linux) docker container, you need to define it in all caps (eg SERVEROPTIONS__URLS=http://*:8080) because the env var is already defined in all caps in the image itself

@BluetriX
Copy link

BluetriX commented Nov 13, 2024

Same issue here - I will try the Workaround with the all caps :-)

Edit: Workaround seems to work - Thanks!

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

No branches or pull requests

4 participants