仅允许 Apache 非 SSL 请求和重定向上的特定端口
我在 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_domain
,website2
也会打开。
我怎样才能防止这种情况发生?如果我要访问 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论