Is the internal port number incorrect for public web access?

I wonder if I’ve bumped into a Fly bug, though it could be an environmental problem of my own making.

I have a PHP-based app, sequoia-proto, which is exposed to the outside world as https. This app is also contacted internally via the private network as http. The listener itself operates on port 8000 for both types of access.

The listener is Apache, with a fairly standard vhost config:

Listen 8000

<VirtualHost *:8000>
    DocumentRoot "/project/public"
    ServerName localhost

    <Directory "/project/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Interestingly, if I access the public port, my phpinfo() says that SERVER_PORT is 80, but I can’t work out where it gets that from; of course the browser sees port 443, and the listener is on 8000. I’ve declared my [http_service] internal_port = 8000, so the Fly proxy would presumably have to use port 8000 to reach my listener.

I note that port 80 is open in Apache, and this just serves the default page. So I don’t think the proxy could be coming via that route.

Does the 80 come from some kind of declaration from the Fly proxy, and if so, does this need fixing? Or is there something I can set in my fly.toml (e.g. an env var) so that my SERVER_PORT is correct? I am using this env var in PHP to explain to other services how to contact the sequoia-proto app over the private network, and that won’t currently work, as it is wrong. It’s not a bother, as I can hard-wire it for now, but it feels worth asking a question about it.

I’m wondering if the area where this might be happening is between apache and php, this StackOverflow seems similar: https://stackoverflow.com/a/15192717 – does the changes done there help at all?

1 Like

Ooh, splendid find Kate, thanks! :trophy: I am trying it right now.

1 Like

Perfect, that was it. Here are the additional Apache directives required:

# These directives should get SERVER_PORT parsed correctly
UseCanonicalPhysicalPort On
UseCanonicalName Off
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.