V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
freezex
V2EX  ›  Apache

apache2.4 virtualhost 设置求解

  •  
  •   freezex · 2015-09-02 16:35:44 +08:00 · 1505 次点击
    这是一个创建于 3151 天前的主题,其中的信息可能已经有所发展或是发生改变。
    apache 上跑了一个 111.com ,和其它几个配置相同的网站,访问都很正常
    现在的问题是:直接使用 IP 访问,或者使用指向此 IP 的域名(没有配置 virtualhost )访问就会跳到 111.com
    我所期望的结果是以上情况直接 403 就好了,所以我又加了一个 noip 的 virtualhost ,但并不能解决问题,又不知道问题出在那里

    111.com 配置:

    <VirtualHost *:80>
    ServerName www.111.com
    ServerAlias 111.com

    DocumentRoot /data/webapps/111
    <Directory /data/webapps/111/>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.111.com [NC]
    RewriteRule ^/(.*)$ http://www.111.com/$1 [L]

    ProxyPass /images !
    ProxyPass /css !
    ProxyPass /js !
    ProxyPass /release !
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>


    NOIP 的配置

    <VirtualHost _default_:80>
    Redirect 403 /
    UseCanonicalName Off
    </VirtualHost>
    2 条回复    2015-09-02 17:23:30 +08:00
    freezex
        1
    freezex  
    OP
       2015-09-02 17:12:20 +08:00
    我把 noip 配置加个 ip 的 servername 然后加载顺序放到第 1 就解决了
    rubixlai
        2
    rubixlai  
       2015-09-02 17:23:30 +08:00
    突然想起来 2.4 没有 namevirtualhost 了...
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5597 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 01:43 · PVG 09:43 · LAX 18:43 · JFK 21:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.