Changes

Jump to navigation Jump to search
3,644 bytes added ,  12:51, 17 June 2016
Line 108: Line 108:  
apt-get install nginx
 
apt-get install nginx
    +
===== nginx configuration =====
 +
 +
<pre>
 +
/etc/nginx/sites-available# more off
 +
##
 +
# You should look at the following URL's in order to grasp a solid understanding
 +
# of Nginx configuration files in order to fully unleash the power of Nginx.
 +
# http://wiki.nginx.org/Pitfalls
 +
# http://wiki.nginx.org/QuickStart
 +
# http://wiki.nginx.org/Configuration
 +
#
 +
# Generally, you will want to move this file somewhere, and start with a clean
 +
# file but keep this around for reference. Or just disable in sites-enabled.
 +
#
 +
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
 +
##
 +
 +
# Default server configuration
 +
#
 +
server {
 +
        listen 80 default_server;
 +
        listen [::]:80 default_server;
 +
 +
        server_name openfoodfacts.eu *.openfoodfacts.eu;
 +
 +
        # SSL configuration
 +
        #
 +
        # listen 443 ssl default_server;
 +
        # listen [::]:443 ssl default_server;
 +
        #
 +
        # Self signed certs generated by the ssl-cert package
 +
        # Don't use them in a production server!
 +
        #
 +
        # include snippets/snakeoil.conf;
 +
 +
        root /home/off/html;
 +
 +
        # Add index.php to the list if you are using PHP
 +
        index index.html index.htm index.nginx-debian.html;
 +
 +
        location ~ ^/(images|js|rss|data|files|resources|foundation)/ {
 +
                # First attempt to serve request as file, then
 +
                # as directory, then fall back to displaying a 404.
 +
                try_files $uri $uri/ =404;
 +
        }
 +
 +
        location = /robots.txt {
 +
                try_files $uri $uri/ =404;
 +
        }
 +
 +
        location / {
 +
                proxy_set_header Host $host;
 +
                proxy_set_header X-Real-IP $remote_addr;
 +
                proxy_pass http://127.0.0.1:8001/cgi/display.pl?;
 +
        }
 +
 +
        location /cgi/ {
 +
                proxy_set_header Host $host;
 +
                proxy_set_header X-Real-IP $remote_addr;
 +
                proxy_pass http://127.0.0.1:8001;
 +
        }
 +
 +
        # deny access to .htaccess files, if Apache's document root
 +
        # concurs with nginx's one
 +
        #
 +
        #location ~ /\.ht {
 +
        #      deny all;
 +
        #}
 +
}
 +
</pre>
 +
 +
/etc/nginx/sites-enabled# ln -s /etc/nginx/sites-available/off off
 +
rm default
 +
 +
service nginx restart
 +
 +
To check for errors:
 +
 +
systemctl -l status nginx.service
 +
 +
===== Apache configuration =====
 +
 +
off.conf:
 +
 +
<pre>
 +
/etc/apache2/sites-available# cat off.conf
 +
# LoadModule perl_module modules/mod_perl.so
 +
 +
PerlWarn Off
 +
PerlRequire /home/off/cgi/startup.pl
 +
 +
 +
<Location /cgi>
 +
SetHandler perl-script
 +
PerlResponseHandler ModPerl::Registry
 +
PerlOptions +ParseHeaders
 +
Options +ExecCGI
 +
Require all granted
 +
</Location>
 +
 +
 +
<VirtualHost *>
 +
DocumentRoot /home/off/html
 +
ServerName openfoodfacts.eu
 +
ErrorLog /home/off/logs/error_log
 +
CustomLog /home/off/logs/access_log combined
 +
LogLevel debug
 +
ScriptAlias /cgi/ "/home/off/cgi/"
 +
 +
<Directory /home/off/html>
 +
Require all granted
 +
</Directory>
 +
 +
</VirtualHost>
 +
 +
PerlPostReadRequestHandler My::ProxyRemoteAddr
 +
 +
</pre>
 +
 +
 +
<pre>
 +
/etc/apache2/sites-enabled# ls -lrt
 +
total 0
 +
lrwxrwxrwx 1 root root 35 Jun 13 22:12 000-default.conf -> ../sites-available/000-default.conf
 +
/etc/apache2/sites-enabled# rm 000-default.conf
 +
/etc/apache2/sites-enabled# ln -s ../sites-available/off.conf off.conf
 +
</pre>
 +
 +
Port 8001
 +
 +
<pre>
 +
 +
/etc/apache2# vi ports.conf
 +
 +
#Listen 80
 +
Listen 8001
 +
 +
</pre>
 +
 +
service apache2 restart
 +
 +
To check for errors:
 +
 +
systemctl -l status apache2.service
 +
 +
mkdir /home/off/logs
    
==== Product Opener ====
 
==== Product Opener ====
Line 153: Line 299:  
vi /home/cgi/Config2.pm
 
vi /home/cgi/Config2.pm
 
-> put right values for server domain, home path, and mongodb database name
 
-> put right values for server domain, home path, and mongodb database name
 +
</pre>
 +
 +
 +
===== robots.txt =====
 +
 +
Since we will run a copy of OFF on a separate domain, add a line to forbid robots completely.
 +
 +
<pre>
 +
/home/off/html# vi robots.txt
 +
User-agent: *
 +
Disallow: /
 +
Disallow: /cgi
 +
Disallow: /code
 +
~
 
</pre>
 
</pre>

Navigation menu