Commit a94d640a authored by Joseph Weston's avatar Joseph Weston
Browse files

replace apache config with nginx

parent ec29d0ad
Pipeline #4101 passed with stage
in 17 seconds
......@@ -372,7 +372,7 @@ REDIRECTIONS = []
DEPLOY_COMMANDS = {
'default': [
"rsync -rlv -e 'ssh -i deploy_key' --delete --filter 'P doc/*' output/* kwant@kwant-project.org:",
"rsync -lv -e 'ssh -i deploy_key' htaccess-apache kwant@kwant-project.org:/.htaccess",
"rsync -lv -e 'ssh -i deploy_key' nginx.conf kwant@kwant-project.org:/nginx.conf",
]
}
......
<IfModule mod_mime.c>
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</IfModule>
# Do not treat Python files as CGI scripts.
<FilesMatch \.py$>
SetHandler default-handler
</FilesMatch>
RewriteEngine on
# We don't need more than that.
RewriteOptions MaxRedirects=2
# Redirect /foo/index.html to /foo/
RewriteRule ^(|.*/)index\.html$ /$1 [R=301,L]
# Redirect /foo/bar.html to /foo/bar only if a html file was requested by the
# browser. Without the condition the following rewrite rule leads to a
# redirection loop.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
# Rewrite /foo/bar to /foo/bar.html if the latter exists.
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*[^/])$ /$1.html [L]
# Remove trailing slash if the requested directory does not exist.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]
Redirect 302 /contact /doc/latest/pre/authors
Redirect 302 /authors /doc/latest/pre/authors
Redirect 302 /citing /doc/latest/pre/citing
Redirect 302 /cite /doc/latest/pre/citing
Redirect 302 /license /doc/latest/pre/license
Redirect 302 /download /install
# Redirect old tutorial URLs to new ones.
# The tutorial numbers refer to the tutorial enumeration in Kwant 1.2.x
Redirect 302 /doc/1/tutorial/tutorial1 /doc/1/tutorial/first_steps
Redirect 302 /doc/1/tutorial/tutorial2 /doc/1/tutorial/spin_potential_shape
Redirect 302 /doc/1/tutorial/tutorial3 /doc/1/tutorial/spectrum
Redirect 302 /doc/1/tutorial/tutorial4 /doc/1/tutorial/graphene
Redirect 302 /doc/1/tutorial/tutorial5 /doc/1/tutorial/superconductor
Redirect 302 /doc/1/tutorial/tutorial6 /doc/1/tutorial/plotting
## Generic rules ##
# try exact URI, then directory, then HTML document.
location / {
try_files $uri $uri.html $uri/ @root-redirect;
}
location @root-redirect {
rewrite ^/contact$ /doc/latest/pre/authors permanent;
rewrite ^/authors$ /doc/latest/pre/authors permanent;
rewrite ^/citing$ /doc/latest/pre/citing permanent;
rewrite ^/cite$ /doc/latest/pre/citing permanent;
rewrite ^/license$ /doc/latest/pre/license permanent;
rewrite ^/download$ /install permanent;
}
## Prettify URLs ##
#redirect */index.html => */ and *.html => *
rewrite ^(.*/)index.html $1 permanent;
rewrite ^(.*[^/])\.html$ $1 permanent;
# For folders, initially look for /index.html
location ~ ^(.*)/$ {
try_files $1/index.html @folder-redirect;
}
# else try removing the trailing slash
location @folder-redirect {
rewrite ^(.*)/ $1 permanent;
}
## Specific rules ##
# serve compressed svg correctly
location ~ \.svgz$ {
add_header Content-Encoding gzip;
add_header Content-Type image/svg+xml;
}
# make sure that we don't serve this configuration file!
location /nginx.conf {
return 404;
}
## Tutorial redirects ##
location /doc/1/tutorial {
try_files $uri $uri/ $uri.html @tutorial-redirect;
}
# Redirect old tutorial URLs to new ones.
# The tutorial numbers refer to the tutorial enumeration in Kwant 1.2.x
location @tutorial-redirect {
rewrite ^/doc/1/tutorial/tutorial1$ /doc/1/tutorial/first_steps permanent;
rewrite ^/doc/1/tutorial/tutorial2$ /doc/1/tutorial/spin_potential_shape permanent;
rewrite ^/doc/1/tutorial/tutorial3$ /doc/1/tutorial/spectrum permanent;
rewrite ^/doc/1/tutorial/tutorial4$ /doc/1/tutorial/graphene permanent;
rewrite ^/doc/1/tutorial/tutorial5$ /doc/1/tutorial/superconductor permanent;
rewrite ^/doc/1/tutorial/tutorial6$ /doc/1/tutorial/plotting permanent;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment