php 如何禁用 cPanel URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9107237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:11:19  来源:igfitidea点击:

How to disable cPanel URLs

phpapachewebcpanel

提问by Tabrez Ahmed

I use cPanel for hosting my website. I have noticed that if anyone who visits my website happens to be a web developer, he can always reach my cPanel Login page via mydomain.com:2082, mydomain.com/cpanel, etc.. It is better to not let the visitors know what control panel I use. I want to disable these URLs. To myself log in to cpanel, I will use the alternate URL provided by my Web Host which is something like a.myhost.com/cpanel.

我使用 cPanel 来托管我的网站。我注意到,如果访问我网站的任何人碰巧是 Web 开发人员,他总是可以通过mydomain.com:2082mydomain.com/cpanel等访问我的 cPanel 登录页面。最好不要让访问者知道我用什么控制面板。我想禁用这些 URL。我自己登录到 cpanel,我将使用我的 Web 主机提供的备用 URL,类似于a.myhost.com/cpanel

As a work around, I also changed the main domain and added my main website as an addon domain. But even that didn't work and addondomain.com:2082and addondomain.com/cpanelshowed up the cpanel login and I was able to login there using cpanel username and password.

作为一种解决方法,我还更改了主域并将我的主网站添加为附加域。但即使这样也不起作用,addondomain.com:2082addondomain.com/cpanel显示了 cpanel 登录名,我能够使用 cpanel 用户名和密码登录那里。

Please help me hide these pages from the public world. At least addondomain.com:2082or addondomain.com/cpanelshould throw a 404(preferable) or 403 or anything.

请帮助我将这些页面隐藏在公共世界之外。至少addondomain.com:2082addondomain.com/cpanel应该抛出 404( preferable) 或 403 或任何东西。

I use cPanel 11/x3.

我使用 cPanel 11/x3。

Even my hosting provider is not able to help me with this. Anybody who know anything about this, or implemented this, please help me.

甚至我的托管服务提供商也无法帮助我解决这个问题。任何对此有所了解或实施的人,请帮助我。

Thanks in advance....

提前致谢....

回答by pl1nk

Changing default cPanel port.

更改默认 cPanel 端口。

The cPanel port can be changed in /var/cpanel/cpanel.config file.

cPanel 端口可以在 /var/cpanel/cpanel.config 文件中更改。

Just change port=2082 (located in the config file) to anything else.

只需将 port=2082 (位于配置文件中)更改为其他任何内容。

Then running the following commands for the changes to take effect.

然后运行以下命令以使更改生效。

/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
/etc/init.d/httpd restart

Changing/removing default cPanel URLs.

更改/删除默认 cPanel URL。

For the /whm and /cpanel urls, remove/change these lines or similar matched lines located on the /usr/local/apache/conf/httpd.conf file:

对于 /whm 和 /cpanel url,删除/更改位于 /usr/local/apache/conf/httpd.conf 文件中的这些行或类似的匹配行:

 ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
 ScriptAliasMatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
 ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi

Then run the following commands for the changes to take effect.

然后运行以下命令使更改生效。

 /usr/local/cpanel/bin/apache_conf_distiller --update
 /scripts/rebuildhttpdconf
 /etc/init.d/httpd restart

Source and more info

来源和更多信息

回答by Luke Stevenson

From a similar discussion raised on cPanel's Forums - "Changing cPanel URL?" (29 Nov 2010):

来自 cPanel 论坛上的类似讨论 - “更改 cPanel URL?” (2010 年 11 月 29 日)

There is no way to change the port numbers for cPanel, the WebHost Manager or Webmail. The port numbers are hard-coded into cPanel and there is no configuration option that allows them to be changed.

Even if you edit the httpd.conf file and change the ScriptAlias directives that cause /cpanel, /webmail and /whm to work, they will still be accessible via ports 2082/2083, 2095/2096, and 2086/2087, respectively.

无法更改 cPanel、WebHost Manager 或 Webmail 的端口号。端口号被硬编码到 cPanel 中,并且没有允许更改它们的配置选项。

即使您编辑 httpd.conf 文件并更改导致 /cpanel、/webmail 和 /whm 工​​作的 ScriptAlias 指令,它们仍然可以分别通过端口 2082/2083、2095/2096 和 2086/2087 访问。

(With application, or package specific questions, your best port of call is initially their own forums/helpdesk rather than a general purpose community like StackOverflow.)

(对于应用程序或打包特定问题,您最好的呼叫端口最初是他们自己的论坛/帮助台,而不是像 StackOverflow 这样的通用社区。)

回答by Paul Fresnel

this can be easily done with TCP PORT filtering blocking.

这可以通过 TCP 端口过滤阻塞轻松完成。

Just filter out in iptables every 2082 (may be even 2083) TCP IN and you will have your cpanel port blocked.

只需在每 2082(甚至 2083)TCP IN 中过滤掉 iptables,您的 cpanel 端口就会被阻止。

You can reinstate it when needed adding an ALLOW directory to the same ports.

您可以在需要时将 ALLOW 目录添加到相同端口来恢复它。

Please tell me if you need further help.

如果您需要进一步的帮助,请告诉我。

回答by Shiv Singh

There are times you want to disable automatic to SSL connection while accessing WHM, cPanel, Webmail, so you can access cPanel/WHM via standard ports 2082 and 2086, this is pretty useful if you have SSL issue that's preventing you from loging into your server or cPanel account because it may unable to decrypt your stored password.

有时您想在访问 WHM、cPanel、Webmail 时禁用自动 SSL 连接,以便您可以通过标准端口 2082 和 2086 访问 cPanel/WHM,如果您遇到阻止您登录服务器的 SSL 问题,这将非常有用或 cPanel 帐户,因为它可能无法解密您存储的密码。

Login to WHM >> Tweak Setting >> Uncheck the following options under Redirection

登录 WHM >> 调整设置 >> 取消选中重定向下的以下选项

Always redirect users to the ssl/tls ports when visiting /cpanel, /webmail, etc.

在访问 /cpanel、/webmail 等时,始终将用户重定向到 ssl/tls 端口。

Also you have to uncheck the following option under Security in Tweak Settings.

此外,您必须取消选中 Tweak Settings 中 Security 下的以下选项。

Require SSL for all remote logins to cPanel, WHM and Webmail. This setting is recommended.

所有远程登录 cPanel、WHM 和 Webmail 都需要 SSL。建议使用此设置。

If you are unable to login to WHM backend, you can disable those options from the shell. SSH to the server as root.

如果您无法登录 WHM 后端,您可以从 shell 禁用这些选项。以 root 身份通过 SSH 连接到服务器。

SSH to your server as root

以 root 身份通过 SSH 连接到您的服务器

Open

打开

# nano /var/cpanel/cpanel.configand set the following options to 0 (zero).

# nano /var/cpanel/cpanel.config并将以下选项设置为 0(零)。

alwaysredirecttossl

requiressl

—-

----

alwaysredirecttossl=0

requiressl=0

—–

————

Save the file and exit.

保存文件并退出。

回答by Amir Nasir

  • Login to WHM as root
  • Under server configuration,
  • Click on Tweak settings
  • Click the Redirections tab
  • Check off button for Always redirect to SSL
  • save settings & that will be done
  • 以 root 身份登录 WHM
  • 在服务器配置下,
  • 点击调整设置
  • 单击重定向选项卡
  • 选中始终重定向到 SSL 的按钮
  • 保存设置&这将完成

回答by goldorakforum

I guess you are in a shared hosting environment. Your best shot is to use an htaccess file, be careful! the goal is to redirect any thing like : #http://your-site.tld/cpanel or to a #http://your-site.tld but do not redirect #http://your-provider.tld/cpanle

我猜您在共享托管环境中。最好的办法是使用 htaccess 文件,小心!目标是重定向任何类似的内容:#http://your-site.tld/cpanel 或 #http://your-site.tld 但不要重定向 #http://your-provider.tld/cpanle

RedirectMatch 301 ^/cpanel/$ http://your-site.tld/

RedirectMatch 301 ^/cpanel/$ http://your-site.tld/

RewriteEngine On RewriteCond %{SERVER_PORT} !^2082$ RewriteRule ^(.*)$ http://your-site.tld/folder/$1 [L,R]

RewriteEngine On RewriteCond %{SERVER_PORT} !^2082$ RewriteRule ^(.*)$ http://your-site.tld/folder/$1 [L,R]

As I said, test carefully!

正如我所说,仔细测试!

回答by phpmeh

Can't you use cpanel to put a redirect on the /cpanel directory? Not sure how to get around 2082 w/o more privileges. Possibly your htaccess?

不能用cpanel在/cpanel目录下重定向吗?不确定如何在没有更多权限的情况下绕过 2082。可能是你的 htaccess?

But really, chill out on the cpanel. No one cares that you make your life easier by using cpanel. Most people do. The only people who are going to know are, as you say, developers. And guess what, they use CPanel too.

但实际上,在 cpanel 上放松一下。没有人关心您是否通过使用 cpanel 使您的生活更轻松。大多数人都这样做。正如您所说,唯一会知道的人是开发人员。猜猜看,他们也使用 CPanel。

回答by ionFish

If your hosting provider cannot help you with this, then you're out of luck. Advisable to set a .htaccess rule to redirect /cpanel to the homepage.

如果您的托管服务提供商无法帮助您解决此问题,那么您就不走运了。建议设置 .htaccess 规则以将 /cpanel 重定向到主页。

For your .htaccess:

对于您的 .htaccess:

Redirect /cpanel /

or if it fails,

或者如果失败,

Redirect /cpanel http://your-site.com

回答by Ajit

I have the exact opposite problem, I just linked my domain mtkroms.com to my blogger website but whenever I try to access mywebsite.com/cpanel it redirects to my blogger blog with the 404 page not found :( due to this I cannot setup subdirectories

我有完全相反的问题,我只是将我的域 mtkroms.com 链接到我的博客网站,但是每当我尝试访问 mywebsite.com/cpanel 时,它都会重定向到我的博客博客,但找不到 404 页面:(因此我无法设置子目录