使用身份验证设置 Apache 代理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/724599/
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-09-13 17:28:06  来源:igfitidea点击:

Setting up an Apache Proxy with Authentication

apacheauthenticationproxymod-proxy

提问by Mario Ortegón

I need to set up a proxy with authentication to verify the behavior of an application that connects to the internet.

我需要设置一个带有身份验证的代理来验证连接到 Internet 的应用程序的行为。

I am trying to set-up an Apache installation with forward proxy and authentication, and even though I am close to make it work, I wonder if there is maybe a better way, as the configuration is fairly esoteric.

我正在尝试使用转发代理和身份验证来设置 Apache 安装,即使我已经接近使其工作,我想知道是否有更好的方法,因为配置相当深奥。

How can Apache be configured to work this way?

如何将 Apache 配置为以这种方式工作?

Is there any other good option that is already configured? Maybe some VM or some other software tool, instead of Apache?

有没有其他已经配置好的选项?也许是一些 VM 或其他一些软件工具,而不是 Apache?

回答by Mario Ortegón

For the record, this is how I set up apache to be used as a forward-proxy with basic authentication:

作为记录,这是我如何设置 apache 以用作具有基本身份验证的转发代理:

Open http.conf

打开 http.conf

Uncomment the following LoadModule directives to enable proxy funcionality

取消注释以下 LoadModule 指令以启用代理功能

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Add the following directives to the http.conf to enable authentication

将以下指令添加到 http.conf 以启用身份验证

ProxyRequests On
ProxyVia On

<Proxy *>
    Order deny,allow
    Allow from all
    AuthType Basic
    AuthName "Password Required"
    AuthUserFile password.file
    AuthGroupFile group.file
    Require group usergroup
</Proxy>

Create a password.file using the htpasswd.exe utility. Place it on the Apache Root directory

使用 htpasswd.exe 实用程序创建一个 password.file。将其放在 Apache Root 目录中

htpasswd.exe -c password.file username

Create a group.file using a text editor at the same level as the password.file with the following contents

使用与 password.file 相同级别的文本编辑器创建一个 group.file,其内容如下

usergroup: username

Then run apachectl restartto pick up the configuration changes.

然后运行apachectl restart以获取配置更改。

回答by chburd

I use Squid.

我用鱿鱼

It's quite easy to install it and to setup it with a basic authentication with the "auth_param" directive in the configuration file.

安装它并使用配置文件中的“auth_param”指令进行基本身份验证非常容易。

You will find some samples, understand how it works, and all details about the auth_paramon Squid Website

您将在 Squid 网站上找到一些 示例了解其工作原理以及 有关 auth_param 的所有详细信息