Posted onIntutorialViews: Word count in article: 2.4kReading time ≈2 mins.
Preface
I ran a mail system on my server first. Then I want to run blog system too, but it is hard for me such a outsider to do this. After a long time learning on internet, I leart how to do this.
The solution in iRedmail system
This mail system would listen 80 port and redirect to 443, the https port. The config file for 80 port is in /etc/nginx/sites-available/00-default.conf which does not need to be changed as we also want https. So we only need to change config file for 443 port:
/etc/nginx/sites-available/00-default-ssl.conf
1
vim /etc/nginx/sites-available/00-default-ssl.conf
# # Note: This file must be loaded before other virtual host config files, # # HTTPS server { listen443sslhttp2; listen [::]:443sslhttp2; server_namemail.bbb.enterprises;
root/var/www/html; indexindex.phpindex.html;
include/etc/nginx/templates/misc.tmpl; include/etc/nginx/templates/ssl.tmpl; include/etc/nginx/templates/iredadmin.tmpl; include/etc/nginx/templates/roundcube.tmpl; include/etc/nginx/templates/sogo.tmpl; include/etc/nginx/templates/netdata.tmpl; include/etc/nginx/templates/php-catchall.tmpl; include/etc/nginx/templates/stub_status.tmpl; } server { listen443sslhttp2; listen [::]:443sslhttp2; ssl_certificate/etc/letsencrypt/live/gitea.bbb.enterprises/fullchain.pem; ssl_certificate_key/etc/letsencrypt/live/gitea.bbb.enterprises/privkey.pem; server_namegitea.bbb.enterprises; location/ { proxy_passhttp://localhost:3001/;# this is reverse proxy } location^~/.well-known/acme-challenge/ { default_type"text/plain"; allowall; root/var/www/example.com/; } } server { listen443sslhttp2; listen [::]:443sslhttp2; ssl_certificate/etc/letsencrypt/live/doublefire.chen.bbb.enterprises/fullchain.pem; ssl_certificate_key/etc/letsencrypt/live/doublefire.chen.bbb.enterprises/privkey.pem; server_namedoublefire.chen.bbb.enterprises; root/var/www/blog;# this is vhosts indexindex.html; } server { listen443sslhttp2; listen [::]:443sslhttp2; ssl_certificate/etc/letsencrypt/live/umami.bbb.enterprises/fullchain.pem; ssl_certificate_key/etc/letsencrypt/live/umami.bbb.enterprises/privkey.pem; server_nameumami.bbb.enterprises; location/ { proxy_passhttp://localhost:3000/;# this is reverse proxy } }
This config will result that different user from different domain can be redirected to different destinations(web redirectory or other port).