Skip to content

Commit 6e33665

Browse files
author
Pierre Buyle
committed
Site specific rewrites directives.
1 parent d8380b7 commit 6e33665

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ The following variables are available to configure the role:
8080
- **http**: HTTP server configuration (leave empty to disable HTTP)
8181
- **port**: The port to listen on
8282
- **https**: HTTPS server configuration (leave empty to disable HTTPS)
83-
- **port**: The port to listen on
83+
- **port**: The port to listen on.
8484
- **certificate**: Path to the SSL certificate of the server (in the PEM
8585
format).
8686
- **certificate_key**: Path to the SSL secret key of the server (in the
@@ -94,6 +94,10 @@ The following variables are available to configure the role:
9494
- **limit_conn**: (optional) The limit_conn for the site (defaults to
9595
```arbeit 32```).
9696
- **enabled**: Whether or not the site should be enabled (defaults to true).
97+
* **rewrites**: A list of rewrites directives, using the following structure:
98+
- **regex**: The regular expression used to match the URI.
99+
- **replacement**: The replacement pattern used for the rewrite.
100+
- **flags**: (optiona) The flag parameter for the rewrite.
97101

98102

99103
Examples
@@ -127,8 +131,8 @@ HTTPS but disabled.
127131
certificate: /etc/nginx/ssl/bar.cert
128132
certificate_key: /etc/nginx/ssl/bar.key
129133

130-
Nginx as a Reverse Proxy for a single Drupal 6 sites, without microcaching and
131-
with image hot linking protection.
134+
Nginx as a Reverse Proxy for a single Drupal 6 sites, without microcaching,
135+
with image hot linking protection and a rewrite directive.
132136

133137

134138
- hosts: all
@@ -146,6 +150,10 @@ with image hot linking protection.
146150
root: /var/www/foo
147151
http:
148152
port: 80
153+
rewrites:
154+
- regex: '^/foo-bar.htm$'
155+
replacement: '/foo/bar'
156+
flags: 'permanent'
149157

150158
License
151159
-------

templates/sites-available/drupal-site.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ server {
6060
proxy_http_version 1.1; # keep alive to the Apache upstream
6161
{% endif %}
6262

63+
{% if item.rewrites is defined -%}
64+
{% for rewrite in item.rewrites -%}
65+
## URL rewriting
66+
rewrite {{rewrite.regex}} {{rewrite.replacement}} {{rewrite.flags|default('')}};
67+
{%- endfor %}
68+
{%- endif %}
69+
70+
6371
{% if not nginx_drupal_use_boost -%}
6472
{% if not nginx_drupal_escape_uri -%}
6573
################################################################

0 commit comments

Comments
 (0)