1 (edited by magnogcs 2018-05-31 03:00:18)

Topic: Error vhost Ngxin - 502 Bad Gateway

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

Hi, my mail is working perfectly on my IP (<my.ip.adress>/mail) but I want to do a vhost to access with my domain (webmail.nilin.love), I configured my .conf in /etc/nginx/sites-enabled:


server {
    listen          80;
    server_name webmail.nilin.love;

    location / {
            rewrite ^ https://webmail.nilin.love permanent;
    }

    location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /opt/www/roundcubemail/$fastcgi_script_name;
    }

}

server {
    listen       443;
    server_name  webmail.nilin.love;

    location / {
        root   /opt/www/roundcubemail/;
        index  index.php index.html;
    }

     location ~ \.php$ {
        root            /opt/www/roundcubemail/;
        include         fastcgi_params;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME /opt/www/roundcubemail/$fastcgi_script_name;
        fastcgi_param   SERVER_NAME $http_host;
        fastcgi_ignore_client_abort on;
    }

    ssl                  on;
    ssl_certificate      /etc/ssl/certs/iRedMail.crt;
    ssl_certificate_key  /etc/ssl/private/iRedMail.key;
    ssl_session_timeout  5m;
    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers   on;
}

But return 502 Bad Gateway. What is wrong?

----

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

2

Re: Error vhost Ngxin - 502 Bad Gateway

Try this:

server {
    listen 80;
    server_name webmail.nilin.love;
    return 301 https://$host$request_uri;
}

server {
    listen 80;
    server_name webmail.nilin.love;

    root /opt/www/roundcubemail;
    index index.php index.html;

    include /etc/nginx/templates/misc.tmpl;
    include /etc/nginx/templates/ssl.tmpl;
    include /etc/nginx/templates/roundcube-subdomain.tmpl;
    include /etc/nginx/templates/php-catchall.tmpl;
}