1

Topic: How can I run Odoo and Iredmail together on the same server?

Hi,
I have Odoo version 10 running on my Linux Ubuntu 14.04 LTS server. and I just installed iRedMail-0.9.6 on the same server. I selected to store mail accounts in which in LDAP at the backend.

The output of hostname -f is kvm.mgbcomputers.com.

In my /etc/hostname file I only have kvm as my entry.

Here are the outputs from my /etc/hosts file:

# Generated by SolusVM
127.0.0.1 kvm.mgbcomputers.com kvm localhost localhost.localdomain
::1     localhost localhost.localdomain
198.23.61.15    kvm.mgbcomputers.com

I'm using the same domain "mgbcomputers" for my email. From my nginx configuration file, I included the paths to Odoo application conf file running on port 8069 as well as the path to the configuration file used for my email service but only the email works. I can only access my website if I remove the reference to my email configuration file in the nginx conf file.

How do I make sure that the Odoo website shows when I enter my domain/IP address in the browser and the mail shows when I append /mail to the domain/IP address?

Here are the contents of my nginx.conf file:

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##
   
    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##
    upstream php_workers {
        server unix:/var/run/php-fpm.socket;
    }

    include /etc/nginx/sites-enabled/*;
    #include /etc/nginx/conf.d/*.conf;
   
}


#mail {
#    # See sample authentication script at:
#    # http://wiki.nginx.org/ImapAuthenticateW … ePhpScript
#
#    # auth_http localhost/auth.php;
#    # pop3_capabilities "TOP" "USER";
#    # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#    server {
#        listen     localhost:110;
#        protocol   pop3;
#        proxy      on;
#    }
#
#    server {
#        listen     localhost:143;
#        protocol   imap;
#        proxy      on;
#    }
#}

and
Here are the contents of sites-enable directory file
upstream backend-odoo{
    server 127.0.0.1:8069;
}
   
server {
    server_name mgbcomputers.com;
    listen 80;
    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^/.*$ https://$host$request_uri? permanent;
}

server {
   
    listen 443 default;
   
    #ssl settings
    ssl on;
    ssl_certificate /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;
    keepalive_timeout 60;
   
    # proxy header and settings
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;

    # odoo log files
    access_log /var/log/nginx/odoo-access.log;
    error_log /var/log/nginx/odoo-error.log;
   
    # increase proxy buffer size
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;
   
    # force timeouts if the backend dies
    proxy_next_upstream error timeout invalid_header http_500
    http_502 http_503;
   
    # enable data compression
    gzip on;
    gzip_min_length 1100;
    gzip_buffers 4 32k;
    gzip_types text/plain application/x-javascript text/xml text/css;
    gzip_vary on;
   
    location / {
        proxy_pass http://backend-odoo;
     }

     location ~* /web/static/ {
        # cache static data
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://backend-odoo;
    }

    location /longpolling { proxy_pass http://backend-odoo-im;}

}
upstream backend-odoo-im { server 127.0.0.1:8072; }

Here are the contents of my file in /etc/nginx/conf.d directory:

#
# Note: This file must be loaded before other virtual host config files,
#
# HTTP
server {
    # Listen on ipv4
    listen 80;
    # Listen on ipv6.
    # Note: this setting listens on both ipv4 and ipv6 with Nginx release
    #       shipped in some Linux/BSD distributions.
    #listen [::]:80;
    server_name _;

    root /var/www/html;
    index index.php index.html;

    # Enable Roundcube/SOGo/iRedAdmin in http mode if working with HAProxy
    # with SSL termination enabled.
    #include /etc/nginx/templates/roundcube.tmpl;
    #include /etc/nginx/templates/sogo.tmpl;
    #include /etc/nginx/templates/iredadmin.tmpl;
    #include /etc/nginx/templates/awstats.tmpl;

    include /etc/nginx/templates/php-catchall.tmpl;
    include /etc/nginx/templates/redirect_to_https.tmpl;
    include /etc/nginx/templates/misc.tmpl;
}

# HTTPS
server {
    listen 443;
    server_name _;

    ssl on;
    ssl_certificate /etc/ssl/certs/iRedMail.crt;
    ssl_certificate_key /etc/ssl/private/iRedMail.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    # Fix 'The Logjam Attack'.
    ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/dh2048_param.pem;

    root /var/www/html;
    index index.php index.html;

    # HTTP Strict Transport Security (HSTS)
    #include /etc/nginx/templates/hsts.tmpl;

    # Web applications.
    #include /etc/nginx/templates/adminer.tmpl;
    include /etc/nginx/templates/roundcube.tmpl;
    include /etc/nginx/templates/sogo.tmpl;
    include /etc/nginx/templates/iredadmin.tmpl;
    include /etc/nginx/templates/awstats.tmpl;

    # PHP applications. WARNING: php-catchall.tmpl should be loaded after
    # other php web applications.
    include /etc/nginx/templates/php-catchall.tmpl;

    include /etc/nginx/templates/misc.tmpl;
}

Thanks
Sincerely,
Olalekan Babawale

----

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