免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3480 | 回复: 0
打印 上一主题 下一主题

[Web] apache做反向代理时如何配置达到只允许几个固定的IP访问网站 [复制链接]

论坛徽章:
5
程序设计版块每日发帖之星
日期:2016-04-15 06:20:00每日论坛发贴之星
日期:2016-04-15 06:20:0015-16赛季CBA联赛之八一
日期:2016-07-08 09:20:28操作系统版块每日发帖之星
日期:2016-08-03 06:20:002016科比退役纪念章
日期:2016-10-30 13:59:12
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-06-09 17:55 |只看该作者 |倒序浏览
这是旧的配置文件,配置文件的路径为/etc/apache2/sites-enabled/wy_server_config.bak,内容如下:
<VirtualHost *:80>
    ServerName wy-c.pala-pala.com
    DocumentRoot /opt/nfcm/mobile
    RewriteEngine On
    RewriteRule "^/$" /template/login.html [R=301,L]
    <Directory /opt/nfcm/mobile/>
        DirectoryIndex login.html
        Options -Indexes FollowSymLinks MultiViews
#        Order allow,deny
#        Allow from all
         Order deny,allow
         Deny from all
         Allow from 8.8.8.8
         Allow from 7.7.7.7
         Allow from 6.6.6.6
         Allow from 5.5.5.5
    </Directory>
    Alias /static /opt/nfcm/mobile/static
    ErrorLog ${APACHE_LOG_DIR}/wy-error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/wy-access.log combined
</VirtualHost>

新的配置文件路径为/etc/apache2/sites-enabled/wy_server_config ,文件内容如下所示,做了反向代理
<VirtualHost *:80>
    ServerName wy-c.pala-pala.com

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass / http://127.0.0.1:1337/
    ProxyPassReverse / http://127.0.0.1:1337/

    ErrorLog ${APACHE_LOG_DIR}/wy-error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug
    CustomLog ${APACHE_LOG_DIR}/wy-access.log combined
</VirtualHost>

我现在的目的是要在新的配置文件里面来做只允许几个固定IP地址可以访问,拒绝其它的IP地址,我添加了如下内容:
<VirtualHost *:80>
    ServerName wy-c.pala-pala.com
    DocumentRoot /opt/nfcm/mobile   
        <Directory /opt/nfcm/mobile/>
        DirectoryIndex login.html
        Options -Indexes FollowSymLinks MultiViews
         Order deny,allow
         Deny from all
         Allow from 8.8.8.8
         Allow from 7.7.7.7
         Allow from 6.6.6.6
         Allow from 5.5.5.5
    </Directory>


    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass / http://127.0.0.1:1337/
    ProxyPassReverse / http://127.0.0.1:1337/

    ErrorLog ${APACHE_LOG_DIR}/wy-error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug
    CustomLog ${APACHE_LOG_DIR}/wy-access.log combined
</VirtualHost>

但是重启apache后没有起到任何作用,还是所有IP都可以访问此网站,请问我应该如何来配置才可以达到目的。

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP