Connect Drupal to proxy server to do upgrades on intranet websites
Use Case : Suppose you have a intranet website which is used for organization and you would like to upgrade that website and its module to latest version. For this you would need to use a proxy server.
A proxy server is a computer(server) which will raise the request to Drupal and act as an intermediate between your actual Drupal server and drupal.org.
So possible scenario is like this:
Drupal Website(Actual Server) ⇄ Proxy Server(Intermediate) ⇄ Drupal.org website
1) First you need to add a rule in your proxy server that it can connect to Drupal.org.
2) Then you need to configure your Drupal website in a way that it sends the request to that proxy server.
For point 1) ask your system administrator or server guy to do it.
After configuring point 1) you make sure that its working. To do this quickly, use command line to test if you can connect to this proxy server or not. If you get response on command line then we will go ahead and configure Drupal to connect with this proxy.
wget -e use_proxy=yes -e https_proxy=https : // Username:"PASSWORD" @ YOUR_PROXY_NAME.COM:PORT_NO https: // drupal.org
Supplement your username, password and port number in above command without spaces and wrap your password in double quotes("").
NOTE: If your password contain special characters like $!@ then you need to escape them with "\" backslash.
After running this command if you receive reply like above then you can be sure that your proxy server settings are Good and you can go ahead to configure your Drupal Website.
To configure Drupal:
Install "chr (cURL HTTP Request)" module from https://www.drupal.org/project/chr
Why you install this module is because it supports the requests over "https protocol". Enable it and open your settings.php file from /sites/default/settings.php
You already have below lines in your settings.php file:
/** * External access proxy settings: * * If your site must access the Internet via a web proxy then you can enter * the proxy settings here. Currently only basic authentication is supported * by using the username and password variables. The proxy_user_agent variable * can be set to NULL for proxies that require no User-Agent header or to a * non-empty string for proxies that limit requests to a specific agent. The * proxy_exceptions variable is an array of host names to be accessed directly, * not via proxy. */ # $conf['proxy_server'] = ''; # $conf['proxy_port'] = 8080; # $conf['proxy_username'] = ''; # $conf['proxy_password'] = ''; # $conf['proxy_user_agent'] = ''; # $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost');
Just after above code add these lines and add your credentials:
$conf['http_proxy'] = array( 'server' => 'YOUR_PROXY_SERVER_NAME', 'port' => 'PORT_NUMBER', 'username' => "YOUR_USERNAME", 'password' => "YOUR_PASSWORD", 'exceptions' => array('localhost'), //exceptions if you have any, otherwise leave it as default localhost );
And then add this important line:
$conf['https_proxy'] = $conf['http_proxy'];
The above lines tell Drupal that use same proxy configuration for HTTP and HTTPS.
Now clear your website cache by using admin panel or drush cc all
Then go to /admin/reports/updates/update module update page and click on "check manually" . This time it tries to connect with your proxy to get updates from drupal.org.
If you dont get the results try refresh page and click on "check manually" again.
You can now also configure for weekly or monthly newsletter of Drupal /admin/reports/updates/settings whenever there is an update.
Because you connected your website to drupal.org this will work as well.