NAT port 443 breaks SSL on webserver
Posted: Sat Apr 20, 2024 10:29 pm
Hello,
I’m just setting up my first mikrotik router CCR2004-1G-12S+2XS and…
TL;DR
If I forward port 443 to my webserver on the lan I can reach the server but I get a bad ssl error NET:ERR_CERT_COMMON_NAME_INVALID. If I click proceed anyway, I can load the address, so I’m guessing the NAT forwarding works.
This is my current conf (i've been trying random stuff for hours so may be a bit messy)
My setup
ISP <-> Mikrotik Router <-> pfSense <-> Web server.
Mikrotik router has ip 192.168.100.1
pfSense WAN has ip 192.168.100.2
The LAB subnet in pfSense is on 192.168.2.0/24
The web server is on 192.168.2.50
I have a letsencrypt wildcard cert setup for *.mydomain.com
The webserver is running in a proxmox vm with Nginx as reverse proxy, pointing several subdomain to internal services and vm’s.
I don’t have a static IP address, but I have my domain setup with cloudflare with an A record pointing to my public ipv4. In the webserver I have a cron job checking when my public ip changes and with the cloudflare API i update the A record to point it to the new IP.
This was working fine until I changed my ISP (init7, Switzerland) and I swapped the proprietary router from the previous ISP (Swisscom) with this Mikrotik.
In the previous router i would just forward 80 and 443 to pfSense and in pfSense i have NAT rules to forward to the Web server VM.
I tried the same setup but somehow the wildcard certificate is not working. I see there’s a certificate section in routerOs, so I’m guessing the router is trying to present a cert before forwarding? Dunno, that sounds dumb, but I’m out of ideas.
Ofc before bothering you nice folks I tried to search Google and this forum, but I guess port forwarding is normally confusing for newbies like me so it’s kinda hard to filter the results for my problem.
I found this viewtopic.php?t=114433 where the problem was mostly the ability to access the url from within the LAN (will need to sort that out too sooner or later, but the SSL is a bigger concern atm) & from where I tried the configuration posted by viewtopic.php?t=114433#p567262
And viewtopic.php?t=167632 where they said you can only make it work with by setting your static ip as dest in the NAT rule. I tried, even if that would not be a solution for me with a dynamic IP, but still got same SSL error.
Anyone can point me in the right direction?
Thanks and please don't flame me too hard if this was answered already somewhere else.
I’m just setting up my first mikrotik router CCR2004-1G-12S+2XS and…
TL;DR
If I forward port 443 to my webserver on the lan I can reach the server but I get a bad ssl error NET:ERR_CERT_COMMON_NAME_INVALID. If I click proceed anyway, I can load the address, so I’m guessing the NAT forwarding works.
This is my current conf (i've been trying random stuff for hours so may be a bit messy)
Code: Select all
# 2024-04-20 20:38:36 by RouterOS 7.14.3
# software id = **ELIDED**
#
# model = CCR2004-1G-12S+2XS
# serial number = **ELIDED**
/interface bridge
add name=lan
add name=wan protocol-mode=none
/interface ethernet
set [ find default-name=sfp28-2 ] fec-mode=fec91
/ip pool
add name=dhcp_pool0 ranges=192.168.100.2-192.168.100.254
/ip dhcp-server
add address-pool=dhcp_pool0 interface=lan name=dhcp1
/ipv6 dhcp-server
add address-pool=v6pool interface=lan name=v6server
/port
set 0 name=serial0
set 1 name=serial1
/interface bridge port
add bridge=lan interface=sfp28-1
add bridge=wan interface=sfp28-2
add bridge=lan interface=sfp-sfpplus1
add bridge=lan interface=sfp-sfpplus2
add bridge=lan interface=sfp-sfpplus3
add bridge=lan interface=sfp-sfpplus4
add bridge=lan interface=sfp-sfpplus5
add bridge=lan interface=sfp-sfpplus6
add bridge=lan interface=sfp-sfpplus7
add bridge=lan interface=sfp-sfpplus8
add bridge=lan interface=sfp-sfpplus9
add bridge=lan interface=sfp-sfpplus10
add bridge=lan interface=sfp-sfpplus11
add bridge=lan interface=sfp-sfpplus12
add bridge=lan interface=ether1
/ipv6 settings
set accept-router-advertisements=yes
/ip address
add address=192.168.88.1/24 comment=defconf interface=ether1 network=\
192.168.88.0
add address=192.168.100.1/24 interface=lan network=192.168.100.0
/ip dhcp-client
add interface=wan
/ip dhcp-server network
add address=192.168.100.0/24 gateway=192.168.100.1
/ip firewall filter
add action=accept chain=input connection-state=established,related
add action=accept chain=input protocol=icmp
add action=accept chain=input in-interface=lan
add action=drop chain=input
add action=fasttrack-connection chain=forward connection-state=\
established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related
add action=accept chain=forward out-interface=wan
add action=accept chain=forward connection-nat-state=dstnat
add action=drop chain=forward
/ip firewall nat
add action=masquerade chain=srcnat out-interface=wan
add action=masquerade chain=srcnat out-interface=lan src-address=\
192.168.100.0/24
add action=dst-nat chain=dstnat dst-address-type=local dst-port=80,443 \
in-interface=wan protocol=tcp to-addresses=192.168.100.2
/ip service
set telnet address=192.168.100.0/24 disabled=yes
set ftp address=192.168.100.0/24 disabled=yes
set www address=192.168.100.0/24 disabled=yes
set ssh address=192.168.100.0/24 port=65535
set www-ssl address=192.168.100.0/24
set api address=192.168.100.0/24 disabled=yes
set winbox address=192.168.100.0/24
set api-ssl address=192.168.100.0/24 disabled=yes
/ipv6 address
add from-pool=v6pool interface=lan
/ipv6 dhcp-client
add add-default-route=yes interface=wan pool-name=v6pool pool-prefix-length=\
56 request=address,prefix use-interface-duid=yes
/ipv6 firewall filter
add action=accept chain=forward connection-state=established,related \
in-interface=wan out-interface=lan
add action=drop chain=forward in-interface=wan out-interface=lan
/ipv6 nd
set [ find default=yes ] interface=lan managed-address-configuration=yes mtu=\
1500 other-configuration=yes
/system clock
set time-zone-name=**ELIDED**
/system note
set show-at-login=no
/system package update
set channel=testing
/system routerboard settings
set enter-setup-on=delete-key
ISP <-> Mikrotik Router <-> pfSense <-> Web server.
Mikrotik router has ip 192.168.100.1
pfSense WAN has ip 192.168.100.2
The LAB subnet in pfSense is on 192.168.2.0/24
The web server is on 192.168.2.50
I have a letsencrypt wildcard cert setup for *.mydomain.com
The webserver is running in a proxmox vm with Nginx as reverse proxy, pointing several subdomain to internal services and vm’s.
I don’t have a static IP address, but I have my domain setup with cloudflare with an A record pointing to my public ipv4. In the webserver I have a cron job checking when my public ip changes and with the cloudflare API i update the A record to point it to the new IP.
This was working fine until I changed my ISP (init7, Switzerland) and I swapped the proprietary router from the previous ISP (Swisscom) with this Mikrotik.
In the previous router i would just forward 80 and 443 to pfSense and in pfSense i have NAT rules to forward to the Web server VM.
I tried the same setup but somehow the wildcard certificate is not working. I see there’s a certificate section in routerOs, so I’m guessing the router is trying to present a cert before forwarding? Dunno, that sounds dumb, but I’m out of ideas.
Ofc before bothering you nice folks I tried to search Google and this forum, but I guess port forwarding is normally confusing for newbies like me so it’s kinda hard to filter the results for my problem.
I found this viewtopic.php?t=114433 where the problem was mostly the ability to access the url from within the LAN (will need to sort that out too sooner or later, but the SSL is a bigger concern atm) & from where I tried the configuration posted by viewtopic.php?t=114433#p567262
And viewtopic.php?t=167632 where they said you can only make it work with by setting your static ip as dest in the NAT rule. I tried, even if that would not be a solution for me with a dynamic IP, but still got same SSL error.
Anyone can point me in the right direction?
Thanks and please don't flame me too hard if this was answered already somewhere else.