1

Topic: Nginx virtual host issue

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 2020041601
- Deployed with iRedMail Easy or the downloadable installer? iRedMail easy
- Linux/BSD distribution name and version: Centos 7
- 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.
====
Hello,
I'm having issue trying to setup virtual host with nginx. i have done the ".conf" setup in "/etc/nginx/sites-available" & the respective linking to "/etc/nginx/sites-enabled" .

this is content of example.com.conf:
-----------------------------------------------------------------------------------------
server {
        listen 80;
        listen 443;


    server_name example.com www.example.com;

    location / {
        root  /var/www/example;
        index  index.html index.htm;
        try_files $uri $uri/ =404;
    }

    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
        root  /usr/share/nginx/html;
    }
}

----------------------------------------------------------------------------

the issues i need to clarify:

1. is this the correct contents for the ".conf" file?
2. is this the correct location to put the ".conf" file
3. when i use https:// to access the site, it loads properly. but when i omit the https, it loads the page minus the css stylesheet. What am i doing wrong?

hopefully i am clear with what i'm trying to say, thank you.

----

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

2

Re: Nginx virtual host issue

flyguye wrote:

1. is this the correct contents for the ".conf" file?

Better organize http and https in their own "server {}" block.

flyguye wrote:

2. is this the correct location to put the ".conf" file

Yes.

3

Re: Nginx virtual host issue

Hi Zhang,
thank you for the response.

1. i will reorganize http & https separately.
2. thanks for confirming location.

3. any guidance with this issue?
4. i created a virtual host for "example.com" with the directory root " /var/www/example;" & when i tried
   to go to  "https://example.com/mail" , i get 404 not found.
5. i then created virtual host for "webmail.example.com" with the directory root 
   /opt/www/roundcubemail;" & when i go to "webmail.example.com" , i get the 403 error.
feeling lost trying to work this out. appreciate any help to resolve this, thank you.

4

Re: Nginx virtual host issue

disregard this post, i have found a workaround that works for me. Thank you all