Debian Codegraph @

doc/sources/admin/applications/drupal.rst

raw
1 Drupal
2 ======
3
4 |image0|
5
6 Presentation
7 ------------
8
9 `Drupal <http://drupal.org>`__ is a CMS written in PHP. It can works
10 with external modules to extends its functionalities. One of this module
11 can be used to delegate authentication server to the web server:
12 `Webserver Auth <http://drupal.org/project/Webserver_auth>`__.
13
14 Installation
15 ------------
16
17 Install `Webserver Auth <http://drupal.org/project/Webserver_auth>`__
18 module, by downloading it, and unarchive it in the drupal modules/
19 directory.
20
21 Configuration
22 -------------
23
24 Drupal module activation
25 ~~~~~~~~~~~~~~~~~~~~~~~~
26
27 Go on Drupal administration interface and enable the Webserver Auth
28 module.
29
30 Drupal virtual host
31 ~~~~~~~~~~~~~~~~~~~
32
33 Configure Drupal virtual host like other
34 :doc:`protected virtual host<../configvhost>`.
35
36
37 .. attention::
38
39 If you are protecting Drupal with LL::NG as reverse
40 proxy,
41 :doc:`convert header into REMOTE_USER environment variable<../header_remote_user_conversion>`.
42
43 - For Apache:
44
45 .. code-block:: apache
46
47 <VirtualHost *:80>
48 ServerName drupal.example.com
49
50 PerlHeaderParserHandler Lemonldap::NG::Handler
51
52 ...
53
54 </VirtualHost>
55
56 - For Nginx:
57
58 .. code-block:: nginx
59
60 server {
61 listen 80;
62 server_name drupal.example.com;
63 root /path/to/application;
64 # Internal authentication request
65 location = /lmauth {
66 internal;
67 include /etc/nginx/fastcgi_params;
68 fastcgi_pass unix:/var/run/llng-fastcgi-server/llng-fastcgi.sock;
69 # Drop post data
70 fastcgi_pass_request_body off;
71 fastcgi_param CONTENT_LENGTH "";
72 # Prevent attacks on older Nginx versions (<1.29.5)
73 fastcgi_param HTTP_HOST $host;
74 # Keep original request (LL::NG server will receive /lmauth)
75 fastcgi_param X_ORIGINAL_URI $original_uri;
76 }
77
78 # Client requests
79 location / {
80 auth_request /lmauth;
81 set $original_uri $uri$is_args$args;
82 auth_request_set $lmremote_user $upstream_http_lm_remote_user;
83 auth_request_set $lmlocation $upstream_http_location;
84 error_page 401 $lmlocation;
85 try_files $uri $uri/ =404;
86
87 ...
88
89 include /etc/lemonldap-ng/nginx-lua-headers.conf;
90 }
91 location / {
92 try_files $uri $uri/ =404;
93 }
94 }
95
96 Drupal virtual host in Manager
97 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98
99 Go to the Manager and :doc:`create a new virtual host<../configvhost>`
100 for Drupal.
101
102 Just configure the :ref:`access rules<rules>`.
103
104 If using LL::NG as reverse proxy, configure the ``Auth-User``
105 :ref:`header<headers>`, else no headers are needed.
106
107 Protect only the administration pages
108 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109
110 With the above solution, all the Drupal site will be protected, so no
111 anonymous access will be allowed.
112
113
114 .. attention::
115
116 You cannot use the ``unprotect`` rule because Drupal
117 navigation is based on query strings (?q=admin, ?q=user, etc.), and
118 unprotect rule only works on URL patterns.
119
120 You can create a special virtual host and use `Apache rewrite
121 module <http://httpd.apache.org/docs/current/mod/mod_rewrite.html>`__ to
122 switch between open and protected hosts:
123
124 .. code-block:: apache
125
126 <VirtualHost *:80>
127 ServerName drupal.example.com
128
129 # DocumentRoot
130 DocumentRoot /var/www/html/drupal/
131 DirectoryIndex index.php
132
133 # Redirect admin pages
134 RewriteEngine On
135 RewriteCond %{QUERY_STRING} q=(admin|user)
136 RewriteRule ^/(.*)$ http://admindrupal.example.com/$1 [R]
137
138 LogLevel warn
139 ErrorLog /var/log/httpd/drupal-error.log
140 CustomLog /var/log/httpd/drupal-access.log combined
141 </VirtualHost>
142 <VirtualHost *:80>
143 ServerName admindrupal.example.com
144
145 # SSO protection
146 PerlHeaderParserHandler Lemonldap::NG::Handler
147
148 # DocumentRoot
149 DocumentRoot /var/www/html/drupal/
150 DirectoryIndex index.php
151
152 LogLevel warn
153 ErrorLog /var/log/httpd/admindrupal-error.log
154 CustomLog /var/log/httpd/admindrupal-access.log combined
155 </VirtualHost>
156
157 .. |image0| image:: /applications/drupal_logo.png
158 :class: align-center
159