Topic: Nginx -How to redirect HTTP to another server IP and HTTPS to iRedmail
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9
- Deployed with iRedMail Easy or the downloadable installer? Downloadable
- Linux/BSD distribution name and version: Ubuntu 18.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? iRedAdmin
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
I just completed a working new iRedmail server and all working fine. I also got Let's encrypt working for Roundcube Webmail and IMAP/SMTP.
Before I had port 80 forwarded to another host IP and 433 to iRedmail server. But I had to forward port 80 to iRedmail server because Let's encrypt did not work without it.
Let's encrypt domain/host is set to mail.mydomain.com and it is working fine.
Now my question is that I want forward www.mydomain.com which comes to iRedmail to another server IP on the same LAN/IP subnet. How can I achieve this with the Nginx configurations?
I see currently Nginx forward all port 80 - HTTP traffic to HTTPS and I want forward HTTP to another server IP instead.
in 00-default.conf:
# HTTP
server {
# Listen on ipv4
listen 80;
# Listen on ipv6.
# Note: this setting listens on both ipv4 and ipv6 with Nginx release
# shipped in some Linux/BSD distributions.
#listen [::]:80;
server_name _;
# Redirect all insecure http:// requests to https://
return 301 https://$host$request_uri;
I want to change above to forward to another server IP.
Please help on this.
Mathew
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.