php-java-bridge icon indicating copy to clipboard operation
php-java-bridge copied to clipboard

FastCGI sets SERVER_PORT to the local port instead of the server port

Open stefanofornari opened this issue 2 years ago • 1 comments

In https://github.com/belgattitude/php-java-bridge/blob/146592a8984405a6f360edf719ace96da04bbe63/src/main/java/io/soluble/pjb/servlet/fastcgi/FastCGIServlet.java#L201, which in turns call https://github.com/belgattitude/php-java-bridge/blob/146592a8984405a6f360edf719ace96da04bbe63/src/main/java/io/soluble/pjb/servlet/ServletUtil.java#L97, FastGCI sets SERVER_PORT to the local port. This does not work when the container is behind a proxy or a NAT. If for example you are natting your more router so that the external port is 80, but you run your service on a tomcat on port 8080, SERVER_PORT should be set 80, not 8080. To do so, FastCGI should pic the server port (req.getServerPort()) and may be fall back on req.getLocalPort(), not the other way around.

stefanofornari avatar Feb 25 '23 07:02 stefanofornari

I fixed it here: https://github.com/stefanofornari/php-java-bridge

stefanofornari avatar Feb 25 '23 17:02 stefanofornari