mysql - 仅在服务器中限制对本地地址的访问
问题描述
我在服务器中有多个 Web 应用程序系统,可以使用 122.0.0.1 通过互联网访问。我想使用 192.0.0.0 仅在没有 Internet 连接的情况下访问 localhost/network 中的一个系统。
例如:122.0.0.0/abc 122.0.0.0/def 122.0.0.0/ghi 可以通过互联网访问。但我不想通过互联网访问 122.0.0.0/abc。我想通过 LAN 使用 196.0.0.0/abc 在线访问它。
这可能吗?那怎么办?
谢谢你。
解决方案
在您的 .htaccess 文件中,您可以添加这些行以仅允许特定的 IP 地址:
Order Deny,Allow
Deny from all
Allow from YourIPAdress
您也可以使用此方法,将其包含在您的 .htaccess 或虚拟主机配置文件中:
这里提到:https ://stackoverflow.com/a/23325758/1993548
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} xxx\.xxx\.xxx\.xxx [OR]
RewriteCond %{REMOTE_ADDR} xxx\.xxx\.xxx\.xxy [OR]
RewriteCond %{REMOTE_ADDR} xxx\.xxx\.xxx\.xxz
RewriteRule .* - [L] #do notthing
#if we are here, the IP is not in the allowed list, redirect
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
推荐阅读
- python - 如何在文件中添加引号
- regex - regex ~ delimited string 在看到 ~~ 并跳过一列时变得混乱
- r - 如何在 ggerrorplot 中包含 x 值之间的不等距离?
- azure-devops - 我可以将代码从 Azure devops 推送到 Azure VM 吗?
- pyspark - 在 Azure Databricks 中使用 spark 流将数据加载到 azure blob
- excel - 将表格粘贴到电子邮件中时出现运行时错误 4605
- javascript - React App 在两个地方使用相同的函数,但 API 调用不同。我如何强制它每次都使用root?
- powershell - Powershell - Get-ChildItem 通配符
- upgrade - 产品不兼容:固件适用于 IDG - Datapower
- jquery - datepicker 不是一个函数 bootstrap-datepicker Symfony, webpack