【问题标题】:apache virtual host redirect traffic works in LAN but not WANapache 虚拟主机重定向流量在 LAN 中有效,但在 WAN 中无效
【发布时间】:2016-08-31 14:28:25
【问题描述】:

我有一个由 yahoo 托管的域。

但我使用自己的内部服务器来实际托管我的域和云子域。

所以在雅虎,我将所有 www.mydomain.com 转发到我的静态 ip

<meta http-equiv="refresh" content="0; url=http://111.111.111.111">

以及我所有的子域流量到我的静态 ip:

<meta http-equiv="refresh" content="0;URL=http://111.111.111.111/cloud"  />

我的内部服务器是 Ubuntu 14.04LTS 上的 Apache 2.4.7。我创建了一个虚拟主机站点并启用了它,只要我在 LAN 中它就可以很好地工作。但是,当我在 WAN 上时,Web 浏览器超时,说服务器停止工作。 我想我知道问题出在哪里,但我不知道如何解决它,即重定向到 htpps - 我使用的是 LAN IP。使用我的静态 IP 或我的域名并没有帮助我解决这个问题。这是我为我的虚拟主机启用的站点:

    <VirtualHost *:80>
       ServerAdmin admin@myexample.com
       ServerName www.myexample.com
       ServerAlias myexample.com

       DocumentRoot /var/www/html/example-test/

       Alias /   /var/www/html/example-test/

       ### Redirect /cloud   https://www.myexample.com/cloud
       Redirect /cloud   https://192.168.1.122/cloud
       ### Redirect /cloud   https://111.111.111.111/cloud

       <Directory /var/www/html/example-test>
          Options Indexes FollowSymLinks MultiViews
          AllowOverride All
          Require all granted
       </Directory>

       <Directory /var/www/owncloud>
          Options Indexes FollowSymLinks MultiViews
          AllowOverride All
          Require all granted
       </Directory>

       ErrorLog /var/log/apache_http_myexample.com.error.log
    </VirtualHost>


    ### <VirtualHost www.myexample.com:443>
    <VirtualHost 192.168.1.122:443>
    ### <VirtualHost 111.111.111.111:443>
       ServerAdmin admin@myexample.com
       ServerName www.myexample.com
       ServerAlias myexample.com

       Alias /cloud   /var/www/owncloud
       DocumentRoot /var/www/owncloud/
       ####Configuration for SSL #####
       SSLEngine on
       SSLCertificateFile /etc/apache2/ssl/examplecloud.pem
       SSLCertificateKeyFile /etc/apache2/ssl/examplecloud.key
       #### End of SSL Configuration ####


       <Directory /var/www/owncloud>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Require all granted
       </Directory>

       ErrorLog /var/log/apache_https_cloud.myexample.com.error.log
    </VirtualHost>

~

任何帮助/见解将不胜感激......

谢谢,

【问题讨论】:

    标签: apache ubuntu redirect virtualhost owncloud


    【解决方案1】:

    试试Redirect permanent /cloud https://192.168.1.122/cloud

    如果这不起作用,请尝试更通用的解决方案,将 Redirect 替换为:

    RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}

    【讨论】:

    • 我注意到一件事,我可以从我们的访客网络访问 owncloud ......我没想到会这样。我认为这是 DNS 问题,但现在我认为这是防火墙问题
    猜你喜欢
    • 2014-05-01
    • 2017-07-13
    • 1970-01-01
    • 2018-03-23
    • 2018-12-21
    • 2014-01-19
    • 2016-04-14
    • 2019-11-04
    • 1970-01-01
    相关资源
    最近更新 更多