Hi everyone.
I would like to say Thank you Joshua and everyone else that has posted here you have been a great help and very useful source of information :)
I thought it time to share what I have setup and ask for advice and some help, so here it goes.
I setup OwnCloud 8.2.2, fail2ban and LetsEncrypt
For ownCloud I used Joshua's guide and for Fail2ban and LetsEncrypt I used Zaggynl's post on page 48.
in the hope some of you will point out any mistakes that I have made and help me improve my settings or that my post may help someone else.
Sean, as I say I followed the links below posted by Zaggynl for Letsencrypt the setup was clear & easy to follow.
the setup.
https://adambard.com/blog/using-letsencrypt-with-nginx/
the Config.
https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html and
https://sethvargo.com/getting-an-a-plus-on-qualys-ssl-labs-tester/
I have played around a bit with the config and so far only got a C on SSLabs test page which I'm happy with but would love to improve on ( image is attached )
Configuring Let's Encrypt for nginx with Automatic Renewal
I also setup a crontab for monthly auto renew LetsEncrypt Cert as it only lasts for 90 days and should be renewed 30 days before it runs out, the auto renew should renew it when it gets to within 30 days.
https://johnmaguire.me/2015/12/configuring-nginx-lets-encrypt-automatic-renewal/
my Nginx config is looking a bit of a mess but it seems to work ok I do not profess to understand any of it it's just been a lot of cut and paste then more reading and more cut and paste ;)
I also paid £9 for a domain name from Fasthosts and pointed it to my ip.
if you do use the below config don't forget to run the commented out openssl command that installs the /etc/nginx/dhparam.pem file this makes a big difference to your SSLabs score and i'm sure also to your security.
- # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
- # Generate with: openssl dhparam -out /etc/nginx/dhparam.pem 2048
openssl dhparam -out /etc/nginx/dhparam.pem 2048
I also noticed that for me Nano missed out some ~ * Astrex or Tilde's when re-pasting :( this had me going nuts for a few days)
so here's what it consists of.
Code:
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile off;
keepalive_timeout 65;
gzip off;
server {
listen 80;
server_name your.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name your.domain.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.domain.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem;
ssl_session_cache shared:SSL:50m;
# Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
# Generate with: openssl dhparam -out /etc/nginx/dhparam.pem 2048
ssl_dhparam /usr/local/etc/nginx/dhparam.pem;
ssl_session_timeout 24h;
ssl_buffer_size 1400;
ssl_session_tickets off;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
resolver 8.8.4.4 8.8.8.8 valid=300s;
resolver_timeout 10s;
root /usr/local/www/owncloud;
location = /robots.txt { allow all; access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ^~ / {
index index.php;
try_files $uri $uri/ /index.php$is_args$args;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
client_max_body_size 2048M;
location ~ ^/(?:\.|build|tests|config|lib|3rdparty|templates|data|autotest|occ|issue|indie|db_|console)
{
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_intercept_errors on;
fastcgi_param modHeadersAvailable true;
include fastcgi_params;
}
location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
expires 30d; add_header Cache-Control public;
}
}
}
}