WillyXJ / facileManager

A modular suite of web apps built with the sysadmin in mind.
www.facilemanager.com
GNU General Public License v2.0
85 stars 37 forks source link

[OTHER] Requirement Error: .htaccess ... not port 80 #545

Closed oiLvAcciNe closed 2 years ago

oiLvAcciNe commented 2 years ago

fM Version : 4.1.2 fmDNS Version : 5.1.1

Does fmDNS have any problems working on ports other that port 80 ?

image

What what i am trying to do it to perform a NAT from :8081 to :80 on our fw.

I have fm running in xxx.pt:80 ... (private_ip). Works fine

NAT also works ... it redirects correctly :8081 --> :80

it reaches apache, set up properly, ... but then i get this Requirement Error

Already looked at issues 335 / 461 / 410 ... but i thing in this case it could be a diff issue.

Have already tried some debugging in fm-includes/init.php But have not come to a real conclusion

Some debugging in " if (!defined('INSTALL')) {"

echo "1".$_SERVER['SERVER_NAME']."\
"; echo "2". echo $test_output."\
"; $test_output = isSerialized($test_output) ? unserialize($test_output) : $test_output; echo "3".echo $test_output."\
";

print_r(@dns_get_record($_SERVER['SERVER_NAME'], DNS_A + DNS_AAAA)) ;;echo"\
"; echo "4". $test_output."
"; echo "5". $GLOBALS['FM_URL']."\
"; die();

Output from 8081 shows image

Output from normal 80 image

So it looks like it does not retrieve anything from the var "$test_output" when port is 8081 $test_output = getPostData($GLOBALS['FM_URL'] . 'admin-accounts.php?verify', array('module_type' => 'CLIENT')); $test_output = isSerialized($test_output) ? unserialize($test_output) : $test_output;

For tests purpose have have already configured apache ports/virtual host on port 8081 (first image) but same result. Does it need any other confs like in config.inc.php or other ...

Any ideias, comments? Regards

WillyXJ commented 2 years ago

This looks like your NAT rule may not allow for fM to connect to the NAT IP on 8081 or you need a SNAT due to asymmetric routing. Essentially fM needs to connect to itself for this test and I don't think your SYN-ACK is going back through the firewall.

oiLvAcciNe commented 2 years ago

Not sure if its that. I have iproute on the server ... so everything that comes in one interface will go out in the same interface. But i can try to debug this nat in more detail .. ... Even if i change the direct private ip from port 80 to port 8081 ... i get the same "Requirement Error" ... What is this $test_output looking for?

tks dS

WillyXJ commented 2 years ago

I took a closer look at the code and it does not currently support non-standard ports. If you look in server/fm-modules/facileManager/variables.inc.php line 40 you will see $GLOBALS['FM_URL'] does not contain a server port so it uses standard http/https ports. Until a permanent fix is implemented, you can change that line to:

$GLOBALS['FM_URL'] = $GLOBALS['REQUEST_PROTOCOL'] . '://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $GLOBALS['RELPATH'];
oiLvAcciNe commented 2 years ago

Thanks for looking into it. I think i had already tried manually in init.php changing this to a manual link just to test but with no luck. ... The [HTTP_HOST] var will contain the server port if it is on the url ... there is no need for the $_SERVER['SERVER_PORT'] Tried adding it but i get this from the output:

echo "5-".$GLOBALS['FM_URL']."
"; 5-http://dnsadmin..com:8081:8081/

Yesterday to solve the public snat i had to add the public url (dnsadmin..com) into etc/hosts pointing it to the private ip. (some other users had reported to fix this error like this in the hosts file) Indead the .com:80 ... worked ... but still had issues with port 8081 that i could not understand why ... Now i got it working ... (guess ia had some cache somewhere when trying) Needed: Apache ports allow on 8081 Apache virtual hosts *:8081 /etc/hosts file pointing the .com url public ip to private iptables rule allow from local private to 8081 ... ... I think i got this working now. Thanks for all the time and help around this. dS

_(P.S: the $_SERVER['SERVERPORT'] was not needed)