-
Notifications
You must be signed in to change notification settings - Fork 59
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
Using the docker container with existing Nginx server #75
Comments
Read this thread, maybe it can help. |
@TitanFighter I went through that thread a couple of times. It should have helped but I didnt understand some things. It is because if your answer there that I tried creating a server block for mail.mydomain.com with the prox-pass to the port I specified for the container. That is not working for me as expected. |
FWIW I combined the two answers from the previous thread and have success:
This is the full conf:
Hope this helps. |
@digitalap3 This is most definitely worth a lot. There are just a few things I need to confirm. Where do I place this server block you have defined above? I have placed it in I believe I am getting this error because the host name p.s I have replaced my actual domain with |
My configuration is a little different from yours. The full configuration file is named mail.conf and is placed in The name 'iredmail' is the container's named defined in either the run command with --name iredmail or docker-compose with container_name: iredmail. So when you docker ps you should see a running container named 'iredmail'. Also - and this may be your problem - the nginx container and the iredmail container have to be on the same network. Here is my docker-compose file:
Notice the last block of the iredmail service 'networks: -ngmain'. This is also available with run command. That network was created with the docker network create command and is included in the service block of my nginx reverse proxy container as well. When two containers are on the same network they are 'aware' of each other by the container name and all exposed ports are available to them. So it is not necessary to use localhost or any variation of that or to define any names in /etc/hosts. AFAIK. Apologies if all the network talk is familiar. Hopefully something in there will help. |
@digitalap3 I would just like to say thank you for taking the time to deal with me. It is highly appreciated. I am very new to handling all this Linux VPS stuff and it is very nice to know that people like you exist. I noticed that you mentioned "nginx container". I am not using an Nginx container, only iredmail container. Is it possible to get the iredmail container to "communicate" with the Nginx server I already have installed on my system? |
Yes I thought that was what this was about lol. I am sorry. Too much screen time and initially reading through my own filter of the questions I have. I have several servers behind a main nginx container and was having trouble getting it to reverse proxy. I hope I have not confused you. |
If I am reading you right I think the problem you are having is that you are trying to point your domain to your server. So you are on say google domains putting the ip address of your server in? |
I believe I have successfully pointed my domain to my server. I think the issue is pointing my Nginx server to the iredmail container. so that when i access mail.example.com/iredadmin, that the iredmail container will be "accessed"/"pointed to". |
The only way to access your container is over port 80 or 443 unless you specify a port number. When you try to go to mailserver.example.com the port 80 or 443 is understood. It is pointing to the nginx container that is on port 80. That is why you get the default page - it is from that container. When you put in the specific port number you get access since the container is mapped to that port. The only way to be able to access your iredmail container without putting in a port number is either to map it to 80 and 443 on your server or reverse proxy through the nginx container that is mapped to those ports. That is what I described. |
So how would i forward requests to 81 or 444 when I access mailserver.example.com? |
the only way to access mailserver.example.com is by using the server that is mapped already to 443 and 80. Lets call that Main Server. You would put the mail.conf file in the directory of the Main Server and it would then reverse-proxy all traffic between outside the VPS and into your iredmail container. Everything I initially described beginning with the FWIW post is how to do that. So with that in mind - I am describing how to set up Main Server to reverse proxy to the iredmail server - go back to where we started at 'FWIW'. Especially the part about the Main Server and the iredmail server being on the same named network created with the docker network create command. This is assuming that the Main Server is a docker container as well. |
@digitalap3 I have spent alot of time trying to get this to work. But still no luck. Let me just make sure I understand the situation correctly. The setup I have is Nginx installed directly on my Ubuntu Server. I then have an iredmail container. I want to forward requests made using mailserver.example.com to the iredmail docker container. From what I understand, this is what a reverse proxy does. But I want to use the Nginx server installed directly on my Ubuntu Server. Is this not possible? Is the only way to use the iredmail container to use an Nginx container to reverse proxy to it? and if that is the case, would I need to uninstall the Nginx server I have installed on my Ubuntu Server? |
@ShanahJr it is possible. I have done it few times. Tomorrow I will explain how to do it (need PC). |
@TitanFighter Thank you very much. |
@ShanahJr Regarding this |
@TitanFighter i will try starting docker first then nginx. Instead of using nginx directly on my Linux server? |
@ShanahJr Also you can try nginx config file from here, especially the part
Yes, as shown here. It is reverse proxy nginx which automatically proxies requests to containers which are behind nginx. Your method to install nginx directly on the server is an old approach. |
I have found a solution to my problem. One that is not stressful at all. instead of using |
How about |
using But all is okay with 0.0.0.0 |
I started solving same issue now, but seems to me , only way will be to mount external voulume to container /iredmail/data/custom/nginx/ and do the setup of nginx (inside container) port here. looks amazing the proxy_pass https://0.0.0.0:8443; (nearly no issue i found) but the loading contacts from list , in case of writing message is not in this setup. so seems something still not working properly. |
Ok .. I was playing a bit , and it gets worked with this nginx vhost for me . I did not wanted to customize the iredmail contrainer, and it looks without any issue..
Command runnung iredmail container :
|
I have installed the container but I am only able to access iredmail through https:myip:444/mail or iredadmin. I have an mx record and A record for mail.mydomain.com.
What am I missing? Below are the settings I used
Do I need to create an nginx server block and redirect the request to the port I specified :444? Because I tried that. Below is what I Tried.
when I try accessing mail.mydomain.com/mail in my browser I get the following error -> Nginx 404 NotFound. And when I access mail.mydomain.com I see welcome to Nginx html page
Otherwise everything is wrorking s expected except receiving emails when I use https:myip:444/mail or iredadmin to access the mail server
The text was updated successfully, but these errors were encountered: