Paramos Apache
pi@raspberrypi ~ $ sudo service apache2 stop
Instalamos Nginx (
fuente)
pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get upgrade
pi@raspberrypi ~ $ sudo apt-get install nginx openssl ssl-cert php5-cli php5-sqlite php5-gd
php5-curl php5-common php5-cgi sqlite3 php-pear php-apc curl libapr1 libtool curl
libcurl4-openssl-dev php-xml-parser php5 php5-dev php5-gd php5-fpm memcached php5-memcache varnish
Configuramos Nginx con un solo procesador:
pi@raspberrypi ~ $ sudo vim /etc/nginx/nginx.conf
#/etc/nginx/nginx.conf
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
Arrancamos Nginx:
pi@raspberrypi ~ $ sudo /etc/init.d/nginx start
Abrimos el navegador apuntando a ip de la Raspberry Pi http://192.168.1.10/ y aparecerá
Welcome to nginx!
Nginx pide certificarnos, así que creamos unos para dos años[
*]:
pi@raspberrypi ~ $ sudo openssl req $@ -new -x509 -days 730 -nodes -out /etc/nginx/cert.pem -keyout /etc/nginx/cert.key
Generating a 2048 bit RSA private key
.....+++
........................+++
writing new private key to '/etc/nginx/cert.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:ES
State or Province Name (full name) [Some-State]:MADRID
Locality Name (eg, city) []:MADRID
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyRaspberryPi
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:owncloud.myraspberrypi.tk
Email Address []:myraspberrypi@gmail.com
Les damos permisos
pi@raspberrypi ~ $ sudo chmod 600 /etc/nginx/cert.pem
pi@raspberrypi ~ $ sudo chmod 600 /etc/nginx/cert.key
Creamos la configuración para ownCloud
pi@raspberrypi ~ $ sudo vim /etc/nginx/sites-available/owncloud
Creamos enlace blando
pi@raspberrypi ~ $ sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/
Configuramos /etc/php5/fpm/php.ini
pi@raspberrypi ~ $ sudo vim /etc/php5/fpm/php.ini
# /etc/php5/fpm/php.ini
upload_max_filesize = 1000M
post_max_size = 1000M
# Añadimos al final del fichero
extension = apc.so
apc.enabled = 1
apc.include_once_override = 0
apc.shm_size = 256
Configuramos /etc/php5/fpm/pool.d/www.conf:
pi@raspberrypi ~ $ sudo vi /etc/php5/fpm/pool.d/www.conf
listen = 127.0.0.1:9000
Reiniciamos web server y PHP
pi@raspberrypi ~ $ sudo /etc/init.d/php5-fpm restart
pi@raspberrypi ~ $ sudo /etc/init.d/nginx restart
Y como ya teníamos la instalación de ownCloud con Apache, ya debería estar funcionando.
Desinstalamos Apache
pi@raspberrypi ~ $ sudo apt-get purge apache2
Vamos ha hacer que el deamon-transmission vaya por nuestro Neginx, creamos el fichero de configuración /etc/nginx/sites-available/transmission que quedara así:
# redirect http to https.
server {
listen 80;
server_name torrent.myraspberrypi.tk transmission.myraspberrypi.tk;
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
server_name torrent.myraspberrypi.tk transmission.myraspberrypi.tk;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.key;
# Thats the important part. Most of the tutorial on the net are not Transmission specific
# and don't pass the Transmission-Session Header
location / {
proxy_read_timeout 300;
proxy_pass_header X-Transmission-Session-Id;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# if you changed the port number for transmission daemon, then adjust the
# folllowing line
proxy_pass http://127.0.0.1:9091/transmission/web/;
}
# Also Transmission specific
location /rpc {
proxy_pass http://127.0.0.1:9091/transmission/rpc;
}
location /upload {
proxy_pass http://127.0.0.1:9091/transmission/upload;
}
}
Creamos un enlace blando
pi@raspberrypi ~ $ sudo ln -s /etc/nginx/sites-available/transmission /etc/nginx/sites-enabled/transmission
Ahora la configuración para amule:
# redirect http to https.
server {
listen 80;
server_name amule.myraspberrypi.tk;
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
server_name amule.myraspberrypi.tk;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.key;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:4711/;
proxy_redirect off;
proxy_http_version 1.0;
}
}
Creamos un enlace blandoraspberry pi
pi@raspberrypi ~ $ sudo ln -s /etc/nginx/sites-available/amule /etc/nginx/sites-enabled/amule
Para la red local de casa, crear virtual host y redirigiros desde el /etc/hosts a la ip de la red local que tiene la raspberry py.
No hay comentarios:
Publicar un comentario