Open stefanofornari opened 1 year ago
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.
I fixed it here: https://github.com/stefanofornari/php-java-bridge
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.