简体   繁体   English

配置httpd.conf以允许主机访问我的网站

[英]configure httpd.conf to allow host access to my website

I have a server which is online right now, but requires authentication when accessing, so it is basically closed to everyone but me. 我有一台服务器现在处于联机状态,但是访问时需要身份验证,因此除我以外的所有用户基本上都无法访问。

Thing is, I don't want to "Open" the website to the public, but I need to test my website on different browsers. 问题是,我不想向公众“开放”网站,但是我需要在不同的浏览器上测试我的网站。

One way is to do it from websites like browsershots.org, which requires access to my website. 一种方法是从browsershots.org等网站进行操作,这需要访问我的网站。 But my website is "closed" (requires authentication) from anyone except me. 但是我的网站已被除我以外的任何人“关闭”(要求身份验证)。

I have these lines in my apache2.conf (or httpd.conf as it also is known as): 我的apache2.conf(或也称为httpd.conf)中包含以下行:

 <Directory /var/www>
 AuthType Basic
 AuthName "Some  name"
 AuthUserFile "dir/to/some/file"
 Require user some_user
 </Directory>

These above allows only access to somebody with username "some_user" and a passwords which is located in "dir/to/some/file". 以上这些仅允许使用用户名“ some_user”和位于“ dir / to / some / file”中的密码访问某人。

Now, is there any way to give access to the website from a host also? 现在,是否还可以通过任何方式从主机授予对网站的访问权限?

My problem is like I said, when trying to cross-browser check my website from sites which requires an URL to my website, they are all blocked because of the authentication I have. 我的问题就像我说的那样,当尝试从需要URL到我的网站的站点进行跨浏览器检查我的网站时,由于我具有身份验证,它们都被阻止了。 Do I have to turn off the authentication in order to be able to cross-browser check? 我是否必须关闭身份验证才能进行跨浏览器检查?

Thanks 谢谢

If you could verify what IP address they would be hitting your website from, you could use a combination of the Allow and Deny directives to make sure that only requests originating from browsershots.org's IP address get through. 如果您可以验证他们从哪个IP地址访问您的网站,则可以结合使用Allow和Deny指令来确保仅来自browsershots.org IP地址的请求能够通过。

http://httpd.apache.org/docs/2.0/mod/mod_access.html http://httpd.apache.org/docs/2.0/mod/mod_access.html

You can create a page that shows the visitors IP, visit your site from browsershots.org, then use that in your apache config. 您可以创建一个显示访问者IP的页面,从browsershots.org访问您的站点,然后在apache配置中使用它。

What about if you removed the authentication, but then added PHP code to restrict access by IP, so that the site was only accessible from your own computer? 如果您删除了身份验证,但是又添加了PHP代码以限制IP访问,那该站点只能从您自己的计算机访问,该怎么办? Would that work for your purposes? 这样做对您有用吗? Something like this: 像这样:

http://www.wmtips.com/php/simple-ways-restrict-access-webpages-using.htm#ip http://www.wmtips.com/php/simple-ways-restrict-access-webpages-using.htm#ip

Edit: sjobe has the better plan. 编辑: sjobe有更好的计划。 Same idea, but that way you can still let BrowserShots do the work. 同样的想法,但是那样您仍然可以让BrowserShots完成工作。

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

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