Hello,
This one is super weird for me.
My usecase: I already have my main app running and accessible from the internet:
- server name:
duplicacy-utils.tbp.land
- container name:
telegram-bot
Server:
server {
server_name duplicacy-utils.tbp.land;
listen 443 ssl http2;
listen [::]:443 ssl http2;
include /config/nginx/ssl.conf;
location / {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
# set $upstream_app telegram_bot; # ✅
set $upstream_app telegram-bot; # ❌
set $upstream_port 13337;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}
}
Docker compose of app:
version: "2.4"
services:
telegram-bot:
# container_name: telegram_bot # ✅
container_name: telegram-bot # ❌
image: thebestpessimist/duplicacy-utils-telegram-bot:latest
restart: unless-stopped
mem_limit: 80m
environment:
WEBSERVER_ADDRESS:
WEBHOOK_ROUTE:
TELEGRAM_API_TOKEN:
CERTIFICATE_PATH:
networks:
default:
external: true
name: nginx-common
Now i want to add a test env. This should be a clone of the existing conf, the only different things are:
- server name:
d.tbp.land
- container name:
telegram-bot-test
- the env variables of the container, fed via an
.env
properties file
Server of test:
server {
server_name d.tbp.land;
listen 443 ssl http2;
listen [::]:443 ssl http2;
include /config/nginx/ssl.conf;
location / {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
#set $upstream_app telegram_bot_test; # ✅
set $upstream_app telegram-bot-test; # ❌
set $upstream_port 13337;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}
}
Docker compose of test app:
version: "2.4"
services:
telegram-bot:
# container_name: telegram_bot_test # ✅
container_name: telegram-bot-test # ❌
image: thebestpessimist/duplicacy-utils-telegram-bot:latest
restart: unless-stopped
mem_limit: 80m
environment:
WEBSERVER_ADDRESS:
WEBHOOK_ROUTE:
TELEGRAM_API_TOKEN:
CERTIFICATE_PATH:
networks:
default:
external: true
name: nginx-common
The problem is the following: using dashes in hostname does not work (see the pairs of “” and “
” above) .
When accessing the apps from the internet (my laptop), the first request passes successfully to each of the apps, however starting with the second request, most of the times (but not 100%) the app telegram-bot-test
receives all the requests (so telegram-bot
receives none).
I have tried and tried again, and this always happens .
Now the quirk: if i rename the 2 apps (and update the server configs) to use underscores (_
) instead of dashes (-
), everything is OK (see the pairs of “” and “
” above) .
I have checked both nginx’s error.log
and access.log
and things are as expected in both cases: entries are added in access.log
successfully for both apps in the “working” usecase and the “not working” usecase.
I have also tried pinging the 2 apps at the same time. the pings are ok:
In the screenshot u can see “test” is on the right and “main” is on the left
Here’s a visual representation of all the edited resources:
Another thing which i tried is to create other apps like t-t
and t-t-t
, and these seem to not have issues. Or at least i could not reproduce them in the testing i did.
This leads me to think that something else might be wrong. Could it be something with nginx and the proxy_pass
clause?
Do you have clues as to why hostnames with _
work, but with -
have issues? Nothing else is changes except that.