简体   繁体   English

如何为外部查看者密码保护VHost?

[英]How can I password protect a VHost for external viewers?

I have been struggling with this problem for some time now. 我已经为这个问题苦苦挣扎了一段时间了。 Let me break it down: 让我分解一下:

We have an apache2 server which hosts most of our company's websites. 我们有一个apache2服务器,可托管我们公司的大多数网站。 Each website is a separate vhost. 每个网站都是一个单独的虚拟主机。 One of this vhosts is used by our internal UI Designer to present his latest drafts and projects to both internal users and 3rd party clients. 我们的内部UI设计师使用其中一个虚拟主机向内部用户和第三方客户展示他的最新草稿和项目。 At the moment, this VHost is password protected from the Vhost configuration file using this directive: 目前,此虚拟主机已使用以下指令从Vhost配置文件中受密码保护:

<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride all
   Order allow,deny
   Allow from all
   AuthUserFile /home/secure/passwords
   AuthName "Username and password required"
   AuthType Basic
   Require valid-user
</Directory>

What I need is to make this website available (so NO password prompt) to our internal users meaning a specific IP range. 我需要使我们的内部用户可以访问该网站(因此没有密码提示),这意味着特定的IP范围。 I have tried to use the Allow from 192.168.xxx.xxx option in the above instruction set. 我尝试使用上述指令集中的Allow from 192.168.xxx.xxx选项。 However this is not letting the internal IP through (still asking for a password). 但是,这不会让内部IP通过(仍然要求输入密码)。 So I tried to use our company's external IP address (which you can find on any "what's my IP website"). 因此,我尝试使用我们公司的外部IP地址(您可以在任何“我的IP网站”上找到该地址)。 No luck with that either. 也没有运气。

So for my last attempt, I have created a second vhost which obviously uses a different ServerName. 因此,对于我的上一次尝试,我创建了第二个虚拟主机,该虚拟主机显然使用了不同的ServerName。 Also, in order not to have any conflicts in the configuration file, I have created a symlink to /var/www and called it www2. 另外,为了在配置文件中没有任何冲突,我创建了一个指向/ var / www的符号链接,并将其命名为www2。 Therefore, the Directory directive in the second vhost file looks like this: 因此,第二个vhost文件中的Directory指令如下所示:

<Directory /var/www2/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride none
   Order allow,deny
   Allow from all
</Directory>

However the configuration files are clearly conflicting because with the current configuration I get password protection on both hosts. 但是,配置文件显然存在冲突,因为使用当前配置,我在两台主机上都获得了密码保护。 If I disable this in the first Vhost, I lose it on both. 如果我在第一个虚拟主机中禁用了此功能,则两个都将丢失。

There is no .htaccess file in any of the directories, so there is nothing there to overwrite the configuration. 在任何目录中都没有.htaccess文件,因此没有任何内容可以覆盖配置。 The apache2.conf file has nothing defined related to Auth. apache2.conf文件没有定义与Auth相关的任何内容。

I'm not sure if you require more details, but feel free to ask me anything. 我不确定您是否需要更多详细信息,但随时可以问我什么。

I appreciate the help! 感谢您的帮助!

----edit---- I just want to specify that I can't say 100% that my method of doing it is the correct one. ---- edit ----我只想指定我不能100%地说我的方法是正确的。 Maybe setting up 2 VHosts isn't the solution to my problem. 也许设置2个VHosts不能解决我的问题。 If anyone thinks of a better way of doing it, I'm open to suggestions. 如果有人想办法做的更好,我欢迎您提出建议。 Bottom line is that I need one website to be available to internal users and password protected for anyone else. 最重要的是,我需要一个网站可供内部用户使用,并为其他任何人提供密码保护。

Cheers! 干杯!

have you tried to solve this using Satisfy Directive of Apache? 您是否尝试过使用Apache的Satisfy指令解决此问题? For example: 例如:

  <Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride all
   Order allow,deny
   Allow from all
   AuthUserFile /home/secure/passwords
   AuthName "Username and password required"
   AuthType Basic
   Require valid-user

   Allow from 192.168.1
   Satisfy Any 
  </Directory>

More information can be found here 更多信息可以在这里找到

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

相关问题 如何在 apache vhost 中密码保护 Laravel 站点? - How to password protect Laravel site within apache vhost? 如何在Apache中对mod_proxy后面的应用程序进行密码保护? - How can I password-protect applications behind mod_proxy in Apache? 是否可以在不向每个虚拟主机添加代码的情况下用密码保护apache服务器上的所有虚拟主机? - Is there a way to password protect all vhosts on an apache server without adding code to each vhost? 如何用密码保护节点服务器? - How to password protect a Node server? 如何使用.htaccess保护目录? - How can I protect a directory using .htaccess? 我无法在Windows 8上设置虚拟主机 - I can't set up a vhost on Windows 8 使用Apache从外部IP访问时使用密码保护目录 - Password protect directories when accessed from external IPs using Apache 我如何在本地主机上WAMP Vhost的WordPress URL中有一个点(。) - How can I have a dot(.) in my WordPress URL on WAMP Vhost on localhost 如何创建不传递页面和子目录的VHOST重定向 - How can I create a VHOST redirect that doesn't pass pages and sub directories 如何使用htaccess和htpasswd密码保护ModX网站中的资源? - How do I password protect resources in a ModX Website using htaccess and htpasswd?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM