revolution
revolution copied to clipboard
[2.x] Need to persist non-standard ports in site URL
Bug report
Summary
Currently, when using a non-standard port for https (any one other than 443), the port gets stripped from the site's URL, making it impossible to properly navigate the site. Only the standard ports of 80 and 443 should be stripped. it is not fully resolved in 2.8.2 in this PR and ports like :44333 still gain errors
Step to reproduce
Configure the testing site (with site.local address for example) on :44333 port, login and click Preview site from naiin menu , or View from any resource admin page. You see site.local33/ in the broken url
Observed behavior
in sreenshot below, port :44333 MODX cut ":443" and "33" part breaks the links:
Expected behavior
Port :43333 and other similar must remain in the URL unchanged
Environment
MODX 2.8.5 version, ~~apache/nginx~~ LITESPEED/1.7.16
Thanks for taking time to report this issue. Is this a clean install or an upgrade? Can you check the core/config.inc.php
file and check if the port is defined correctly there?
Thank for quick response!
This is upgrade from MODX 2.8.4, port defined to 443 in config.inc.php
But in my case, port 44333 is port-mapping to the private local network, and inside this lan, site working on :443 but outside - on :44333 an i cant (and dont need, or even should not need, i think) define temporary mapped ports in config.inc.php or something else settings. My engine just shouldn't cut current port, if it not in list of standart ports!
This list is :80 and :443
Thanks for your answer, what's on line 67 of your config file? It should be this:
$http_host .= in_array($_SERVER['SERVER_PORT'], [80, 443]) ? '' : ':' . $_SERVER['SERVER_PORT'];
Sorry for timeout... In my case, it is line 69, but i see something similar. Here is part of my core/config.inc.php file:
From installation date, i edited only config paths and db connect params... But with this config, bug reported above is reproduced
And in line 22:
$https_port = '443';
It sounds like your webserver is not reporting the proper port to PHP. The result suggests it is in fact reporting that the port is 443, so the code is attempting to remove that from the http_host, but fails because the port is actually 44333 (which leaves the 33 without a colon preceding it). If you can get your server to properly report that $_SERVER['SERVER_PORT'] is 44333 and set your https_port configuration to 44333, everything should work properly.
@opengeek I'm looking at the code but $https_port
in the config file seems to be hardcoded to 443
, unless it's in a $_POST value with key httpsport
(but I can't find any reference to it in the code in the setup folder).
https://github.com/modxcms/revolution/blob/8b533fb5d52a6c76673d6323c5001569d1b1e930/setup/includes/config/modconfigreader.class.php#L72
@JoshuaLuckers — then it is missing from the setup. It exists in the CLI setup config XML file, but doesn't look like the UI got a form field for it.
@opengeek hi, Sorry for the long answer. I make tests and prepare PR #16455 draft
he result suggests it is in fact reporting that the port is 443
You are right, my server gives port 443 (because it works on such a port, however, my configuration uses port forwarding to a private network) and nevertheless, the modx frontend works without problems (port 44333) the MODX backend is saved correctly too (mostly).
If you can get your server to properly report that $_SERVER['SERVER_PORT'] is 44333 and set your https_port configuration to 44333, everything should work properly.
In my case: port 44333 is port-mapping to the private local network, and inside this lan, site working on :443 and but outside - on :44333. In this case i should not change port in config.inc.php because this will lead to a breakdown of modx operation inside the network, where now :443
I did a lot of tests and found a solution PR #16455 (it is ready, but now draft, beacuse i cant solve problem with git-detection for only changed lines in first commit 2nd commint with config is well-tested by me, and 3rd commits is a port of this solution for installer)
Problem solved with merge of my PR, thanks all, now i close this issue