[Request] UseCanonicalPhysicalPort


We are using OLS behind a proxy on several servers and almost everything works out of the box. However, some applications tries to redirect users after some actions using the _SERVER["SERVER_PORT"] variable. Since we are running OLS on localhost:9443 por HTTPS and localhost:8088 for HTTP behind a proxy on 443/80, this variable returns the "wrong" value: 9443 and breaks everything.

If I use Apache as backend, I can just turn the UseCanonicalPhysicalPort to off and edit SERVER_PORT to be 443 or 80. But I can't find a way to do the same using OLS.
By the way, I even found a topic about this on LSWS forum: https://www.litespeedtech.com/support/forum/threads/server_port-when-using-proxy-server.3134/

Is there anyway to replicate UseCanonicalPhysicalPort on OLS?



Active Member
I think you an do this way. In the Vhost conf file rewrite block, add a rule to set the env, such as my test case
rewrite  {
  enable                  1
  logLevel                9
  RewriteRule ^(.*) $1 [E=SERVER_ROOT:80]
Wow! You are a genius :D
Thank you very much, David :)

rewrite  {
  enable                  1
  autoLoadHtaccess        1
  RewriteCond %{HTTPS} on
  RewriteRule ^(.*) $1 [E=SERVER_PORT:443]
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*) $1 [E=SERVER_PORT:80]
It worked perfectly =)
Last edited: