Score:0

Allow only specific ports on Apache non-SSL requests and redirect

it flag

I am serving 3 NodeJS websites on Apache. The VirtualHosts of these websites are as follows:

website1

<VirtualHost *:80>
    DocumentRoot "/var/www/html/[website1]"
    ServerName "[website1_domain]"
    ServerAlias "www.[website1_domain]"
    ProxyPass / http://localhost:[website1_port]/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.[website1_domain] [OR]
RewriteCond %{SERVER_NAME} =[website1_domain]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

website2

<VirtualHost *:80>
    DocumentRoot "/var/www/html/[website2]"
    ServerName "[website2_domain]"
    ServerAlias "www.[website2_domain]"
    ProxyPass / http://localhost:[website2_port]/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.[website2_domain] [OR]
RewriteCond %{SERVER_NAME} =[website2_domain]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

website3

<VirtualHost *:80>
    DocumentRoot "/var/www/html/[website3]"
    ServerName "[website3_domain]"
    ServerAlias "www.[website3_domain]"
    ProxyPass / http://localhost:[website3_port]/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.[website3_domain] [OR]
RewriteCond %{SERVER_NAME} =[website3_domain]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

For example, if I go to website1_domain like this http://[website1_domain]:[website2_port] website2 opens even though the domain is website1_domain.

How can I prevent this? If I'm going to website1_domain I want http://localhost:[website1_port]/ to run directly.

in flag
Bind your backend servers to the local interface only instead of all interfaces.
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.