Difference between revisions of "Wifi kiosk"

Jump to navigation Jump to search
→‎..using Nginx: add comments for kiwix-serve / kiwix-manage usage
m (→‎Welcome pages: add location hint for simple welcome page)
(→‎..using Nginx: add comments for kiwix-serve / kiwix-manage usage)
 
(6 intermediate revisions by the same user not shown)
Line 85: Line 85:
[http://nginx.org Nginx] is faster and less resources consuming than Apache in this scenario. This step is an alternative to using Apache, if you installed it just for kiwix, you might as well remove Apache.
[http://nginx.org Nginx] is faster and less resources consuming than Apache in this scenario. This step is an alternative to using Apache, if you installed it just for kiwix, you might as well remove Apache.


* Install nginx: ''aptitude install nginx''
* Install nginx: ''sudo apt-get install nginx''
* Choose between one of the two samples below and save as ''/etc/nginx/sites-available/default''
* Choose between one of the two samples below and save as ''/etc/nginx/sites-available/default''


<syntaxhighlight style="margin:2em;float:left;border-left:1px solid black;" lang="bash">
<syntaxhighlight style="margin:0 0 2em 2em;float:left;border-left:1px solid black;" lang="bash">
server_name localhost kiwix;
server_name localhost kiwix;
root /var/www/kiwix;
root /var/www/kiwix;
Line 100: Line 100:
error_page  404 = /;
error_page  404 = /;
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight style="margin:2em;float:left;border-left:1px solid black;" lang="bash">
<syntaxhighlight style="margin:0 0 2em 2em;float:left;border-left:1px solid black;" lang="bash">
#limit_rate      50k;
#limit_rate      50k;
#limit_rate_after 4k;
#limit_rate_after 4k;
Line 107: Line 107:
limit_req_zone  $binary_remote_addr zone=four:1m rate=4r/s;
limit_req_zone  $binary_remote_addr zone=four:1m rate=4r/s;


# Default server configuration
# Default server configuration, proxying requests to a kiwix-serve instance running on port 4201
#
# - add zim files to a library.xml, see http://www.kiwix.org/wiki/Kiwix-manage
# chown www-data *.zim library.xml
#
# - then start kiwix-serve (uses dropped privileges, like nginx itself):
# sudo -u www-data -g adm bash -c 'kiwix-serve --port=4201 --library library.xml &>/dev/null &'
#
server {
server {
         # comment next three lines if connection or request rate limits are not needed
         # comment next three lines if connection or request rate limits are not needed
Line 142: Line 149:
         location ~ ^/([^/]*_all_|mw|random|search|skin|suggest)(.*)$ {
         location ~ ^/([^/]*_all_|mw|random|search|skin|suggest)(.*)$ {
           # Choose these links as "Home" pages within respective wikis (adjust to your needs)
           # Choose these links as "Home" pages within respective wikis (adjust to your needs)
           rewrite ^/wikipedia_de_all_nopic_2014-11/$
           rewrite ^(/wikipedia_de_all_nopic_2014-11)/$ $1/A/Würmeiszeit.html break;
                  /wikipedia_de_all_nopic_2014-11/A/Würmeiszeit.html break;
           rewrite ^(/rezeptewiki_de_all_2014-06)/$ $1/A/html/L/ä/u/t/Läuterzucker.html break;
           rewrite ^/rezeptewiki_de_all_2014-06/$
                  /rezeptewiki_de_all_2014-06/A/html/L/ä/u/t/Läuterzucker.html break;


           # Skip logging certain uris (each tex formula is a png in zim files..)
           # Skip logging certain uris (each tex formula is a png in zim files..)
Line 159: Line 164:


         location / {
         location / {
           # For "Library" link of Kiwix Server to work (replace HOSTNAME by something like your.server.tld)
           # For "Library" link of Kiwix Server to work (adjust HOSTNAME to your.setup.tld)
           valid_referers "~(localhost|kiwix|HOSTNAME|([0-9]+.){3}[0-9]+)(|:[0-9]+)/[^/]*_all_";
           valid_referers "~(localhost|kiwix|HOSTNAME|([0-9]+.){3}[0-9]+)(|:[0-9]+)/[^/]*_all_";
           if ($invalid_referer != 1) {
           if ($invalid_referer != 1) {
Line 171: Line 176:
         }
         }
}
}
</syntaxhighlight>
</syntaxhighlight><br style="clear:both"/>
<br style="clear:both"/>
 
Now you should get the kiwix-serve rendered page by typing http://kiwix/wp/
Now you should get the kiwix-serve rendered page by typing http://kiwix/wp/ You should also consider to compress and delay writing to the nginx access.log file for performance reasons. The following entry in ''nginx.conf'' will gzip compress and flush log data in 15 minute intervals only:
<syntaxhighlight style="margin:0 0 2em 2em;float:left" lang="bash">access_log /var/log/nginx/access.log combined gzip=9 flush=15m;</syntaxhighlight><br style="clear:both"/>
If you do not care for repeating entries of success messages use ''access_log off;'' directive as shown above to filter out some access patterns from being logged. For further refinements see [http://nginx.org/en/docs/ nginx docs].


== Welcome pages ==
== Welcome pages ==
9

edits

Navigation menu