仅允许 Apache 非 SSL 请求和重定向上的特定端口

发布于 2025-01-16 19:45:41 字数 1718 浏览 4 评论 0原文

我在 Apache 上为 3 个 NodeJS 网站提供服务。这些网站的 VirtualHosts 如下:

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>

例如,如果我像这样访问 website1_domain http:// [website1_domain]:[website2_port] 即使域是 website1_domainwebsite2 也会打开。

我怎样才能防止这种情况发生?如果我要访问 website1_domain 我希望 http://localhost:[website1_port]/ 直接运行。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文