Squid Proxy Server user authentication in centos

Source: Internet
Author: User
Tags centos squid proxy

What should I do if I want to access google or other websites that are inaccessible to Tianchao? The premise is that there must be a VPS that is not in the dtplus Lan.

Method 1: Create a vpn. For details, refer to vpn installation and configuration.

Method 2: Set up a proxy server, which will be described in detail below

1. Install squid

# Yum install squid

2. Add the authenticated user test123

# Htpasswd-c/etc/squid/passwd test123

3. Configure proxy and user authentication
 
# Vim/etc/squid. conf // add the following content
 
Auth_param basic program/usr/lib64/squid/ncsa_auth/etc/squid/passwd // The authentication method is basic. The Authentication program path and password file path

Auth_param basic children 5 // Number of authenticate processes
Auth_param basic credentialsttl 1 hours // authentication validity period
Auth_param basic realm my test prosy // the content displayed in the enter user/password dialog box is displayed in the browser
Acl test123 proxy_auth REQUIRED
Http_access allow test123 // normal users must pass authentication before accessing

4. Open the firewall Port
 
# Iptables-a input-p tcp-m state -- state NEW-m tcp -- dport 3128-j ACCEPT // squid default port, 3128

5. Restart squid.

#/Etc/init. d/squid restart

In this way, the squid proxy is ready. Set the proxy IP address and port in the browser. The authentication box is displayed. Enter the user name and password.

6. php can also use the proxy server
 
Function testCurl ($ url ){
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ gurl );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HTTPPROXYTUNNEL, TRUE );
Curl_setopt ($ ch, CURLOPT_PROXY, "23. 220. *. *: 3128"); // ip/Port
Curl_setopt ($ ch, CURLOPT_PROXYUSERPWD, 'test123: 123456 '); // authenticate the user and password
$ Result = curl_exec ($ ch );
Curl_close ($ ch );
Return $ result;

 
Echo testCurl ("google.com ");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.