dperson / samba

Samba docker container
GNU Affero General Public License v3.0
1.51k stars 511 forks source link

Question about port mapping #463

Open lgy1027 opened 4 weeks ago

lgy1027 commented 4 weeks ago

Hello, I am now using docker to deploy samba. Instead of using the default port, I specify port mapping 139 and 445. The deployment command is as follows:

sudo docker run -it -p 11139:139 -p 11445:445 \
            -v /root/lgy:/share \
            -d dperson/samba -p \
            -u "user1;badpass" \
            -u "user2;badpass" \
            -s "public;/share/public" \
            -s "share_1_2;/share/dir_1_2;yes;no;no;user1,user2;admin;admin;user1与user2专用" \
            -s "share1;/share/dir1;yes;no;no;user1;admin;admin;user1专用" \
            -s "share2;/share/dir2;no;no;no;user2;admin;admin;user2专用"

But when I use windows to link, I get an error image image

Use under linux

bash-5.0# smbclient //10.0.102.50:11445/share1 -U user1
do_connect: Connection to 10.0.102.50:11445 failed (Error NT_STATUS_UNSUCCESSFUL)

I would like to ask if this means that port mapping cannot be specified. If I want to deploy multiple Samba services, will it not work?

sabirovrinat85 commented 4 weeks ago

I'd suggest using local DNS and to point different subdomains for different samba services pointing to the same IP of your containerisation host. Then you could use reverse proxy server to handle requests to different subdomains to docker host ports of smb services accordingly (map the ports of proxy container to be responsible for the usual ports of smb). Maybe(!) there'll be a need in proxy server with stream capabilities, like Haproxy or Traefik, but much simpler Caddy could also do that if you build an image with unofficial layer4 module (it's not hard at all), or you could try Nginx Proxy Manager, which is even simpler than Caddy having WebUI

lgy1027 commented 3 weeks ago

I'd suggest using local DNS and to point different subdomains for different samba services pointing to the same IP of your containerisation host. Then you could use reverse proxy server to handle requests to different subdomains to docker host ports of smb services accordingly (map the ports of proxy container to be responsible for the usual ports of smb). Maybe(!) there'll be a need in proxy server with stream capabilities, like Haproxy or Traefik, but much simpler Caddy could also do that if you build an image with unofficial layer4 module (it's not hard at all), or you could try Nginx Proxy Manager, which is even simpler than Caddy having WebUI

The client connection is fine on Linux, but not on Windows. The default port is used. If the specified port seems to have to be changed a lot, do you have any good suggestions for mounting directories on the server that you want to mount in Windows?

sabirovrinat85 commented 3 weeks ago

Only some thoughts:

Is ping on the smb server works from windows machine?

While samba4 as a share server could be easily configured to use ports other than 139/445, it seems that windows cannot be configured in that way (considering server role), which in turn rises a question if windows as a client works flawlessly connecting to non-standard ports...

My suggestion remains the same - local DNS and reverse proxy, so that you won't need to use non-standard ports for client connections and as a bonus could use domain names as Share1, FamilyPhotos, etc

lgy1027 commented 1 week ago

Only some thoughts:

Is ping on the smb server works from windows machine?

While samba4 as a share server could be easily configured to use ports other than 139/445, it seems that windows cannot be configured in that way (considering server role), which in turn rises a question if windows as a client works flawlessly connecting to non-standard ports...

My suggestion remains the same - local DNS and reverse proxy, so that you won't need to use non-standard ports for client connections and as a bonus could use domain names as Share1, FamilyPhotos, etc

Thanks for your reply, I still don’t quite understand, because I really want to use k8s to deploy multiple samba for different users, so I can’t use the default port. What do you need to do through dns or nginx? I’m not sure about this I'm not very familiar with it. Could you please explain it in detail? Or it would be better if there is a reference document.