nginx_apache webmail with ssl/https

indexs

Verified User
Joined
Jun 11, 2010
Messages
74
Greetings, all around!

I have one issuie with nginx and display roundcube under -> https://webmail.domain.com.
At the moment I have fixed only the part for https://webmail.domain.com/roundcube/ <- like this roundcube page is loaded and works as it should.

I have followed the instruction from here: https://help.directadmin.com/item.php?id=560

But now I`m struggling to make roudcube work directly -> https://webmail.domain.com

First I have setup only webserver=apache to see my apache config (virtual_host2.conf.post and virtual_host2_secur.conf.post) is working without nginx and it did (worked with http://webmail.domain.com and https://webmail.domain.com).

After I have changed to webserver=nginx_apache (added two new configs: nginx_server.conf.post and nginx_server_secure.conf.post), without SSL -> http://webmail.domain.com it works.

With SSL https://webmail.domain.com it displays default hosting panels page.

The nginx_server_secure.conf.post:

Code:
|?DOCROOT=`HOME`/domains/`DOMAIN`/private_html|
|?REALDOCROOT=`HOME`/domains/`DOMAIN`/private_html|
|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/var/tmp:/usr/local/lib/php/|
server
{     
	   listen |IP|:|PORT_443| ssl|SPACE_HTTP2|;
       |MULTI_IP|

       server_name mail.|DOMAIN|;

       root /var/www/html/roundcube;
       index index.php index.html index.htm;
	   
       access_log /var/log/nginx/domains/|DOMAIN|.log;
       access_log /var/log/nginx/domains/|DOMAIN|.bytes bytes;
       error_log /var/log/nginx/domains/|DOMAIN|.error.log;
	   
	ssl_certificate |CERT|;
	ssl_certificate_key |KEY|;


|*if HAVE_PHP1_FPM="1"|
       # use fastcgi for all php files
       location ~ \.php$
       {
               try_files $uri =404;
               fastcgi_split_path_info ^(.+\.php)(/.+)$;
               include /etc/nginx/fastcgi_params;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include /etc/nginx/nginx_limits.conf;

               if (-f $request_filename)
               {
                       fastcgi_pass unix:/usr/local/php|PHP1_RELEASE|/sockets/webapps.sock;
               }
			   
	    root /var/www/html/roundcube;
            index index.php index.html index.htm;
}
|*endif|

|*if HAVE_NGINX_PROXY="1"|
	    location /
       {
               # access_log off;
	       proxy_buffering |PROXY_BUFFERING|;
               proxy_pass https://127.0.0.1:|PORT_8081|;
	       proxy_set_header X-Client-IP      $remote_addr;
               proxy_set_header X-Accel-Internal /nginx_static_files;
               proxy_set_header Host             $host;
               proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
			   

        }
		
       location /nginx_static_files/
       {
			   
	       # access_log  /var/log/nginx/access_log_proxy;
               root       /var/www/html/roundcube/;
               internal;
       }
|*endif|

       # deny access to apache .htaccess files
       location ~ /\.ht
       {
               deny all;
       }
}
It seems the problem is in routing, but I can figure it out.
Any help would be appreciated!

Thank you!
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,934
Location
GMT +7.00
Hello,

Shouldn't it be

Code:
       server_name webmail.|DOMAIN|;
instead of

Code:
       server_name mail.|DOMAIN|;
?
 

indexs

Verified User
Joined
Jun 11, 2010
Messages
74
I have also checked log file -> tail -f /var/log/nginx/domains/riepunams.lv.error.log

I the correct path to roundcube, but the page dose not display index.php


2019/06/27 22:23:04 [error] 12388#0: *31 openat() "/var/www/html/roundcube/logo.png" failed (2: No such file or directory), client: 000.000.000.000, server: mail.riepunams.lv, request: "GET /logo.png HTTP/2.0", upstream: "https://127.0.0.1:8081/logo.png", host: "mail.riepunams.lv", referrer: "https://mail.riepunams.lv/"

p.s. client IP is masked.
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,934
Location
GMT +7.00
Will you show how a final nginx.conf and httpd.conf look for the domain?

p.s. you nginx templates are outdated, they use |NGINX_PHP_CONF| token now for PHP-FPM part.
 

indexs

Verified User
Joined
Jun 11, 2010
Messages
74
Good morning, zEitEr!

The problem was stupid and simple at the same time by config file: virtual_host2_secur.conf.post was missing "e" virtual_host2_secure.conf.post
Now it`s working!

Regarding outdated nginx templates, I will play with templates and make them work with new standards.
Thank you!
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,934
Location
GMT +7.00
Hi,

Good catch. I'm glad you've managed to get it working.

I believe the main feature you are missing is redirects: www <=> non-www, and http <=> https
 
Top