简体   繁体   English

WHM/cPanel - 多个 IP 指向一个根目录

[英]WHM/cPanel - Multiple IPs pointing to one root dir

we need our new dedicated IP address (and all future ones) to "point" to the same root directory of our VPS' "parent" domain (main domain with all business logic, where $_SERVER['host'] is detected to connect associated files etc. )我们需要新的专用 IP 地址(以及所有未来的 IP 地址)“指向”我们 VPS 的“父”域(具有所有业务逻辑的主域,其中检测到 $_SERVER['host'] 连接的主域)的同一根目录相关文件等)

So, for example, domain.net (xxx146) should show content of domain.com (xxx170) etc因此,例如,domain.net (xxx146) 应显示 domain.com (xxx170) 等的内容

We have list of dedicated IPs, added to WHM.我们有专用 IP 列表,已添加到 WHM。 We have number of domain names, with those IPS as DNS A records.我们有许多域名,这些 IPS 作为 DNS A 记录。 We have added those domains via cPanel to point to the same public_html..我们通过 cPanel 添加了这些域以指向相同的 public_html..

在此处输入图片说明 But all the domains resolve to : cgi-sys/defaultwebpage.cgi with "SORRY! If you are the owner of this website, please contact your hosting provider:" error.但是所有域都解析为:cgi-sys/defaultwebpage.cgi 并带有“对不起!如果您是本网站的所有者,请联系您的托管服务提供商:”错误。

Any suggestions?有什么建议? This is supposed to be quite an easy task, but clearly - not so.这应该是一项相当容易的任务,但显然 - 并非如此。

Thank you谢谢

Why do you need many IP address?为什么需要多个IP地址? one IP address should be enough for what you want to do.一个 IP 地址应该足以满足您的需求。 Indeed HTTP/1.1 protocol is meant for this purpose: many different domains for one IP.事实上,HTTP/1.1 协议就是为了这个目的:一个 IP 有许多不同的域。 In your VPS you can use for example "Apache" as a Web server with this basic configuration:在您的 VPS 中,您可以使用例如“Apache”作为具有以下基本配置的 Web 服务器:

ceate/edit on "/etc/apache2/sites-available/" example.com.conf :在“/etc/apache2/sites-available/”example.com.conf 上创建/编辑:

<VirtualHost *:80>

DocumentRoot /home/user/pulic_html
ServerName example.com

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

</VirtualHost>

then create/edit example.org.conf:然后创建/编辑 example.org.conf:

<VirtualHost *:80>

ServerName example.org
Redirect permanent / http://example.com/

</VirtualHost>

and so on..等等..

then to enable your configuration :然后启用您的配置:

a2ensite example.com.conf example.org.conf
sudo service apache2 restart

If you still want to use many IPs you can install apache in every machine hosting the IP, then redirect to your main site/domain( http://example.com ), as shown above.如果您仍然想使用多个 IP,您可以在每台托管该 IP 的机器上安装 apache,然后重定向到您的主站点/域( http://example.com ),如上所示。 Otherwise, if your hosting provider allow, you can redirect your children domain to your parent domain from your provider website with GUI.否则,如果您的托管服务提供商允许,您可以使用 GUI 从您的提供商网站将您的子域重定向到您的父域。

here is the solution.这是解决方案。 It is not ideal bot it looks like there's not much we can do, having cPanel/WHM installed.这不是理想的机器人,安装 cPanel/WHM 后,我们似乎无能为力。

<VirtualHost x.x.x.x:443>
    ServerName domain.net
    ServerAlias www.domain.net
    DocumentRoot /home/user/public_html
    #todo common contact mail
    ServerAdmin support@domain.net
    UseCanonicalName Off
    <IfModule mod_suphp.c>
        suPHP_UserGroup user user
    </IfModule>
    <IfModule ssl_module>
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/domain.net/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/domain.net/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/domain.net/chain.pem
        SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    </IfModule>
    <IfModule headers_module>
        RequestHeader set X-HTTPS 1
    </IfModule>
</VirtualHost>
  • redirect from 80 to 443 set separately:从 80 重定向到 443 分别设置:
RewriteEngine On 
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM