Skip to main content
jalejoFTNT
Staff
Staff
October 24, 2024

Technical Tip: How to restrict HTTPS access to an HTTPS custom port and specific country

  • October 24, 2024
  • 0 replies
  • 2567 views
Description This article describes how to restrict HTTPS access to an HTTPS custom port and a specific country.
Scope FortiGate.
Solution

Prerequisites:

  • HTTPS access must be enabled on the WAN interface.

WAN HTTPS enabled.jpg

 

 

config system interface
    edit "WAN"
        set vdom "root"
        set ip 10.15.15.1 255.255.255.0
        set allowaccess https  <---
        set type physical
    next
end

 

  • Determine which port is being used for HTTPS:

In the GUI:

Go to System -> Settings -> Administration Settings -> HTTPS port.

 

HTTPS-custom-port-3.jpg

 

On CLI:

 

config system global
    set admin-sport 16443
end
 
show full system global | grep admin-sport
    set admin-sport 16443

 

  • Have access to FortiGate from the LAN interface or using a console cable.

How to configure:

 

  1. Configure a firewall address to permit a specific country.

In the GUI:

Go to Policy & Objects -> Addresses -> Create new:

 

HTTPS-custom-port-1.jpg

 

Select the Geography type and select OK.

 

In the CLI:

 

config firewall address
    edit "Allow-Country"
        set type geography
        set country "CO"
    next
end

 

  1. Configure a custom HTTPS port.

In the GUI:

Go to Policy & Objects -> Services -> Create new:

 

HTTPS-custom-port-2.jpg

 

On CLI:

 

config firewall service custom
    edit "Custom-HTTPS"
        set tcp-portrange 16443
    next
end

 

  1. Create a local-in policy:

Starting in v7.6, local-in policies can be configured in the Web GUI or via the CLI (refer to Technical Tip: Creating a Local-In policy (IPv4 and IPv6). In v7.4 and earlier, local-in policies can only be configured via the CLI.

 

For CLI config, use the following commands:

config firewall local-in-policy
    edit 1
        set intf "wan1"
        set srcaddr "Allow-Country"
        set dstaddr "all"
        set action accept
        set service "Custom-HTTPS"
        set schedule "always"
    next
    edit 2
        set intf "wan1"
        set srcaddr "all"
        set dstaddr "all"
        set service "Custom-HTTPS"
        set schedule "always"
    next

end

 

Note: Instead of allowing countries, a similar approach can be followed to allow certain subnets or IP addresses. Refer to:

Technical Tip: Configure local-in policy to restrict unauthorized administrative access with custom HTTPS port

Technical Tip: Use local-in policy to restrict unauthorized login attempts to administrative access of FortiGate

Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Fortinet Flag the Hack. Wednesday, August 26, 9:00 AM - 5:00 PM ET, COSM, Atlanta, GA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!