nginxwebservernginx-configmail-serveriredmail

How to host some websites with a mail server (iRedAdmin)?


I have installed iRedMail on my server and it is managing my emails perfectly. I would like to use this server also as website server. I went into the nginx config /etc/nginx/sites-enabled/ 00-default-ssl.conf 00-default.conf

when I add www.mywebsite.com.conf it doesn't seem to be render.

mywebsite is not deploy, my nginx conf is simple.

Is it related to iRedAdmin config? since the file 00-default-ssl.conf use the templates. Does the templates in nginx override the conf file ?

Is there something I have missed on my conf ?

Thanks in advance !

content of 00-default-ssl.conf

    server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name mail.mywebsite.com;

    root /var/www/html/iredmail;
    index index.php index.html;
    
    include /etc/nginx/templates/misc.tmpl;
    include /etc/nginx/templates/ssl.tmpl;
    include /etc/nginx/templates/iredadmin.tmpl;
    include /etc/nginx/templates/roundcube.tmpl;
    include /etc/nginx/templates/sogo.tmpl;
    include /etc/nginx/templates/netdata.tmpl;
    include /etc/nginx/templates/php-catchall.tmpl;
    include /etc/nginx/templates/stub_status.tmpl;  
}

that is my conf for my www.mywebsite.conf :

server {
        root /var/www/html/mywebsite.com/public/;
        index index.html ;

        server_name site.mywebsite.com;

        location / {
                alias /var/www/blog/html/public;
                index index.html;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/site.mywebsite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/site.mywebsite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

Solution

  • Using Nginx, create another .conf file in /etc/nginx/sites-available/site.mywebsite.com.conf with the server{} block then symbol link the file to sites-enabled/ folder.

    use a different webroot folder from /var/www/html because in this one the index.html append /mail to the host