Installed nginx with iredmail; how to add web content & test without DNS change

I have an existing website at a hosting service. I have contracted with
a
virtual server company and have installed iredmail, which in turn
installs
nginx, [Oddly, Appache2 as well, though probably not relevant.]

Since I have an ip address for the server, I am able to test the email
service. [Only email to accounts on the server since the MX record still
goes to the old hosting company,] Iredmail has a web based mail manager,
so
it has associated html code.

Iredmail puts its html in /var/www. I put a test page in /var/www2 and
added a location line to point to it, but I’m confused on how to set
this up
since it is like hosting two websites at the same IP address. Obviously
I
need to test the server before changing the DNS.

I’m thinking maybe do something in /etc/hosts. Or do I just try to merge
the
html from iredmail with my own html? That is change the index.html from
iredmail to mail.html?

One additional complication may be that iredmail requires https while my
html does not.

Posted at Nginx Forum:

On Tue, Apr 28, 2015 at 9:17 PM, gariac [email protected] wrote:

added a location line to point to it, but I’m confused on how to set this up
since it is like hosting two websites at the same IP address. Obviously I
need to test the server before changing the DNS.

How is nginx configured? Could you post it here? It might be easier to
understand what is going on looking at it.

Also, what is the difficult are you having? With the nginx
configuration or the iredmail? I don’t know about the later though.

Best regards,


Thiago F.

On Tue, Apr 28, 2015 at 08:17:42PM -0400, gariac wrote:

Hi there,

Iredmail puts its html in /var/www. I put a test page in /var/www2 and
added a location line to point to it, but I’m confused on how to set this up
since it is like hosting two websites at the same IP address. Obviously I
need to test the server before changing the DNS.

To test the server, probably all you need is that your client resolves
the desired hostname to the new IP address.

You can test with something like

curl -i -H Host:host.domain http://ip.add.re.ss/

or by changing name resolution for your browser (for example, by using
your local “hosts” file).

There probably shouldn’t be any nginx changes for this to happen.

f

Francis D. [email protected]

I think I failed to explain my problem correctly. It seems to me
whatever I
do for the test would be on the server side, not client side. Studying
your
reply, I think your solution maps domain.com to ipaddress (dotted quad)
from
the client side. What I need to do is have the one ip address I have for
the
server host iredmail and my website.

Iredmail creates an index.html in /var/www with contents

I created a /var/www2 with a different index.html, but I don’t see how
nginx
would know which directory to use.

I was able to get nginx working with my website prior to having iredmail
on
the same server. Having both services on the same server is what
confuses
me.

Posted at Nginx Forum:

On Fri, May 01, 2015 at 08:50:51PM -0400, gariac wrote:

Hi there,

I think I failed to explain my problem correctly. It seems to me whatever I
do for the test would be on the server side, not client side. Studying your
reply, I think your solution maps domain.com to ipaddress (dotted quad) from
the client side. What I need to do is have the one ip address I have for the
server host iredmail and my website.

I had misunderstood your issue.

See Module ngx_http_core_module and links.

Basically: some web applications can sensibly be installed
in a “subfolder” of the web space, so you can access them at
http://www.example.com/app1/. Other web applications insist on owning
the full web space, so you must use http://app1.example.com/.

If iredmail is in the latter group, then in your one nginx conf file,
have one server{} block for iredmail, and a separate server{} block
(with a different server_name) for your website.

I created a /var/www2 with a different index.html, but I don’t see how nginx
would know which directory to use.

If you have separate server{} blocks, nginx picks the one to use based
on its rules.

I was able to get nginx working with my website prior to having iredmail on
the same server. Having both services on the same server is what confuses
me.

They can be in the same nginx instance without a problem.

The can only be in the same nginx server{} block if both play nice.

In that case, you must decide how you want nginx to handle the request
for “/”, and configure it to do that.

f

Francis D. [email protected]

Thanks halozen and Francis. Knowing where to read in the manual is half
the
battle.

I think I will tackle combining the iredmail code into my own website
since
at the moment I only have one domain I am going to put on this server.

With flexibility comes head scratching. It seems like nginx has two ways
of
doing everything.

Posted at Nginx Forum:

You need to find how to create virtual host for inginx which involves
setting up sites-available/domain file, symlink it to sites-enabled/ and
restart nginx. You would also need to edit you host file on your pc to
simulate dns resolve for testing purposes.