1

Topic: nginx configuration question

==== Required information ====
- iRedMail version (check /etc/iredmail-release):
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
======== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7
- Linux/BSD distribution name and version: Centos 7.4
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): Maria
- Web server (Apache or Nginx): nginx
- Manage mail accounts with iRedAdmin-Pro? yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Hi,

I will start this off by saying I am an nginx novice. I have a lot of experience with Apache.
I am trying to get nginx to redirect http(s)://mail.mydomain.com to https://mail.example.com. In apache all I need to do is add 1 line to the config file similar to: RewriteRule ^/?iredadmin/(.*) https://mail.example.com/iredadmin/$1 [R,L] and I get the desired behavior.

In looking at the nginx configuration I do not see an easy way to accomplish what I want.

To be clear I have SOGo and iRedAdmin-pro installed. No roundcube.

Suggestions?

Regards,

Tom

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: nginx configuration question

There're many Nginx tutorials, you can do a quick Google search. for example:
https://stackoverflow.com/questions/102 … l-in-nginx

3

Re: nginx configuration question

OK, so maybe I asked the wrong question. I already saw the above article and
many others like it.

The problem I am having is figuring out where to put the new server block. I am very reluctant to make changes to things I do not fully understand.

In order to maintain your scheme, What I think I will need to do is something
like the following:

Add something like sites-available/{00-mydomain.com.conf,00-mydomain.com-ssl.conf}
and the 00-mydomain.com.conf file needs to contain something like:

server {
    include /etc/nginx/sites-conf.d/mydomain.com.conf/*.conf;
}

and the 00-mydomain.com-ssl.conf file needs to contain something like:

server {
    include /etc/nginx/sites-conf.d/mydomain.com-ssl/*.conf;
}

Then in sites-conf.d/ I need a couple of directories something like:
sites-conf.d/{mydomain.com,mydomain.com-ssl} and in there I need to
basically add the info for my new server block.

In order to activate that I will need a symlink from
sites-available/{00-mydomain.com.conf,00-mydomain.com-ssl.conf} to sites-enabled/

Is this the general idea?

Do I need to duplicate what is in sites-conf.d/default* into sites-conf.d/mydomain.com* 
and then make additions or modifications or do I leave default alone and just
add the server block that will do the redirection?

If we are leaving the default enabled, do my modifications need a higher or
lower priority then the default?

I suspect you are doing this to make ansible configuration easier but IMO this
needs better documentation then what you have in the changelog.

Regards,

Tom

4

Re: nginx configuration question

Please allow me to explain the schema a little bit:

*) We split Nginx configuration to different directories, so that it's easier for sysadmin to manage it with Ansible or other tools (Puppet, Chef, etc). Small pieces are easy to modify then a flat big file which contains all settings. Note: we're talking about a "Core + Custom" configuration mode we're going to implement in the future.

What is "Core + Custom" mode?

- iRedMail maintains the core config files to give you a full-featured mail server, sysadmins are not expected to touch these config files.

- Sysadmins always need to modify some settings to match their needs. In this case, sysadmin can add (new) modular config files in particular directories and reload/restart services to load new config files.

If you understand this strategy, it will be easier for you to understand why it's split to small pieces in different directories.

*) Although it's splited, but it's your server and you're the sysadmin, you're free to do whatever you want. For example, you can use a flat file for Nginx config file. In your case, you can do this:

- Create file /etc/nginx/sites-available/mydomain.com.conf (NOTE: no '00-' prefix in file name), it should contains the Nginx `server {}` block for your web domain. You're free to add http and https support in same file (so no more /etc/nginx/sites-available/mydomain.com-ssl.conf required).

- Create a symbol link of 'sites-available/mydomain.com.conf' to 'sites-enabled/' directory, then reload Nginx.

5

Re: nginx configuration question

hi buddy and Zhang
I upgraded the latest version
can you give me a virtualhost example of roundcubemail?
I saw the configuration but I don't know how to set it
I want set the mail point to mail.host.com. without /mail
many thanks

6

Re: nginx configuration question

We have one shipped in iRedMail:
https://bitbucket.org/zhb/iredmail/src/ … omain.tmpl