How do I get current server port from cgi variables

When I’m on SSL lucee returns port 80 and secure as 0.

What changes do I need to make to return the correct values.

To get the correct CGI remote_addr/remote_host I followed these instructions.

and updated my server config to use

<Engine name="Catalina" defaultHost="">
<Valve className="org.apache.catalina.valves.RemoteIpValve" />


I assume you’re doing SSL termination outside Tomcat - so you’d want to
make sure that service (nginx/apache/haproxy/pound/etc) is advertising the
actual port information via headers. (i.e. X-Forwarded-Proto,
X-Forwarded-For, etc)

Based on that you’ll want to configure RemoteIPValve. Here’s mine

Such that is my internal IP. Note the ip comparisons are
regex, not subnets.