1

Topic: Adding Django Site to IredMail

==== BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version: 0.9.9 MARIADB edition.
- Downloadable installer
- Linux distribution: Ubuntu Server 18.04LTS
- Store mail accounts in which backend: MySQL
- Web server: Nginx
====

The situation is this:
I has installed IredMAil and is working perfect. (A lot of troubles with dns and ssl but thats other history).
Now I have installed in the same VM a Django Syte that is running with Gunicorn in port 8001 and is Publish in port 81 with nginx.
(I can tell cause if i do a: wget localhost:81 > I download the index of my django page)

BUUUUT!

If I try to get from another pc inside or outside the network to this webpage it always redirect me to /mail/ in port 443 and give me the iredmail page... can you help me please???

It dont matter even if I hardcode the http://cannava.com.ar > It send me to: https://cannava.com.ar/mail/


00-default-ssl.conf
#
# Note: This file must be loaded before other virtual host config files,
#
# HTTPS
server {
    listen 443;
    server_name _;

    index index.php index.html;
   
    location /mail/ {
    root /var/www/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;
}

cannavase.conf
#
# Note: This file must be loaded before other virtual host config files,
#
# HTTP
server {
    listen 81;
#    listen 4431 ssl;

    server_name cannava.com.ar;

#    ssl on;
#    ssl_certificate /etc/nginx/ssl/cannava.pem;
#    ssl_certificate_key /etc/nginx/ssl/cannava.key;

    # Permitir subir cannavases de hasta 50M
    root /opt/cannavase/cannavase;

    access_log /opt/cannavase/nginx_access.log;
    error_log /opt/cannavase/nginx_error.log;

    location /archivos/ {
    }
    location /static/ {
    }

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
        proxy_read_timeout 600;
        proxy_pass http://localhost:8001/;
    }
}

Important:
I put port 81 cause this VM is behind a HAPROXY that send both port 80 to 81 and 443 to 443.


Thanks for your time, hugs!

----

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

2

Re: Adding Django Site to IredMail

I suppose you should add port number in URL?
http://cannava.com.ar:81/

3

Re: Adding Django Site to IredMail

Dont worry... i have decided to change my way of doing this.

I put django site and iredmail together in port 443. this is my:
00-default-ssl.conf file:
server {
    listen 443;
    server_name cannava.com.ar;

    include /etc/nginx/templates/ssl.tmpl;

    location /archivos/ {
        root /opt/cannavase/cannavase;
        access_log /opt/cannavase/nginx_access.log;
        error_log /opt/cannavase/nginx_error.log;
    }

    location /static/ {
        root /opt/cannavase/cannavase;
        access_log /opt/cannavase/nginx_access.log;
        error_log /opt/cannavase/nginx_error.log;
    }

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
        proxy_read_timeout 600;
        proxy_pass http://localhost:8000/;
    }

    location /mail/ {
        root /var/www/html;
        index index.php index.html;

    }


    include /etc/nginx/templates/misc.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;
}

Now I have this problem:
https://cannava.com.ar/mail/ and https://cannava.com.ar/iredadmin work great!
every subpage from my django syte like https://cannava.com.ar/somos work great!

BUUUUUUUUUUUUUUT! When i try to get the homepage with https://cannava.com.ar/ it automatically redirect to https://cannava.com.ar/mail...

how can I avoid that???

4 (edited by mmandrille 2019-10-23 14:24:57)

Re: Adding Django Site to IredMail

I think find the reason:

@cannavase:/var/www/html$ cat index.html
<html><head><meta HTTP-EQUIV="REFRESH" content="0; url=/mail/"></head></html>

So I have to take out this from
     location /mail/ {
        root /var/www/html;
        index index.php index.html;
    }

Lets try that!

Edit> that didnt work... im trying a lot of stuff xD