Score:1

httpd redirect one port number to another

pg flag

We are trying to redirect requests on port 8555 to port 8443. In our httpd.conf file, we have the following:

<VirtualHost *:8555>
SSLEngine on
# SSL configuration that is irrelevant to this question

RewriteEngine on
RewriteRule ^(.*)$ https://%{HTTP_HOST}:8443%{REQUEST_URI}
</VirtualHost>

However, when a user goes to https://example.con:8555/foo, they get redirected to https://example.com:8555:8443/foo instead of https://example.com:8443/foo. How do I correct this?

Score:2
in flag

HTTP_HOST contains the value set by the "Host:" request header. You could try using SERVER_NAME instead, which contains the value of the ServerName directive, if configured in your VirtualHost block. Otherwise httpd tries to find the ServerName via reverse DNS.

RewriteRule ^(.*)$ https://%{SERVER_NAME}:8443%{REQUEST_URI}

Another option, if you only have one server name you can just write it in the RewriteRule directly, you don't have to use variables for this.

RewriteRule ^(.*)$ https://example.com:8443%{REQUEST_URI}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.