Setup iRedMail Admin Site in Nginx on Ubuntu 12.04

不问归期 提交于 2019-12-03 21:01:48

I began with fresh Ubuntu 12.04.2 LTS installs, 2 servers setup with default options, only adding OpenSSL when installing the server to access remotely. One server is the mail server, one is the SSL web server.

On the mail server I downloaded the newest version of iRedMail (0.8.4 as of this post) and ran through the install to setup the mail server components. I use mySQL as my backend, so I checked that option, typed in the rest of my domain information and password, and on the last page only left DKIM, iRedAdmin, and Fail2Ban checked.

Onto the web nginx SSL server... Again default install with only OpenSSL added.

Here are the commands run as root to install the needed components for running the admin panel:

apt-get update
apt-get install nginx uwsgi uwsgi-plugin-python python-pip python-mysqldb
pip install jinja2
pip install web.py

I then created the locations for where I wanted iRedAdmin to be placed and setup

mkdir /var/www/iredadmin
mkdir /var/www/iredadmin/static
mkdir /var/www/iredadmin/python-home

and copied the iredadmin installed directly from the mail server and placed it into the new server's directory.

scp -r user@mail-server:/usr/share/apache2/iredadmin/* /var/www/iredadmin/

Created the uwsgi application config ini file located at: /etc/uwsgi/apps-available/iredadmin.ini

[uwsgi]
plugins=python
vhost=true
socket=/var/run/uwsgi/app/iredadmin/iredadmin.socket

Created the softlink to enable the application:

ln -s /etc/uwsgi/apps-available/iredadmin.ini /etc/uwsgi/apps-enabled/iredadmin.ini

Create the virtual host config for nginx located at: /etc/nginx/sites-available/iredadmin

server {
    listen 443 ssl; ## listen for ipv4; this line is default and implied
    access_log /var/log/nginx/iredadmin.access.log;
    error_log /var/log/nginx/iredadmin.error.log;

   ssl_certificate /etc/nginx/ssl/star.crt;
   ssl_certificate_key /etc/nginx/ssl/server.key;
   ssl_session_timeout 5m;
   ssl_protocols SSLv3 TLSv1;
   ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
   ssl_prefer_server_ciphers on;

    server_name iredadmin.server.com;

    location / {
    root /var/www/iredadmin/;
    uwsgi_pass unix:///var/run/uwsgi/app/iredadmin/iredadmin.socket;
    uwsgi_param UWSGI_PYHOME /var/www/iredadmin/python-home;
    uwsgi_param UWSGI_CHDIR /var/www/iredadmin;
    uwsgi_param UWSGI_SCRIPT iredadmin;
    include uwsgi_params;
    }

    location /static {
    alias /var/www/iredadmin/static/;
        }

    location ~ /\.ht {
            deny all;
    }
}

and created a softlink to enable the site for nginx:

ln -s /etc/nginx/sites-available/iredadmin /etc/nginx/sites-enabled/iredadmin

Finally, restart the services and head to your server name from your browser:

/etc/init.d/uwsgi restart
/etc/init.d/nginx restart
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!