Start with the installation of NGINX

sudo apt-get install nginx

Create your cert and key

First create a temporary directory and move the files to their final resting place once they have been built (the first cd is just to make sure we are in our home directory to start with):

mkdir temp
cd temp

Generate a new key, you will be asked to enter a passphrase and confirm:

openssl genrsa -des3 -out server.pkey 1024

Remove the passphrase by doing this, we do this because we don’t won’t to have to type this passphrase after every restart.

openssl rsa -in server.pkey -out server.key

Next we need to create a signing request which will hold the data that will be visible in your final certificate:

openssl req -new -key server.key -out server.csr

This will generate a series of prompts like this: Enter the information as requested. And finally we self-sign our certificate.

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

We only need two of the files in the working directory, the key and the certificate. But before we can use them they need to have their ownership and access rights altered:

sudo chown root:www-data server.crt server.key
sudo chmod 640 server.crt server.key


And then we put them in a sensible place:

sudo mkdir /etc/ssl/nginx
sudo chown www-data:root /etc/ssl/nginx
sudo chmod 710 /etc/ssl/nginx
sudo mv server.crt server.key /etc/ssl/nginx/

We now have the key and certificate on the final location. We can now tell nginx where the files are and how they will behave.

Create the nginx site configuration file

We create a new configuration file

sudo vi /etc/nginx/sites-available/owncloud

with the following content:

IMPORTANT: You will need to change all references to in the following file to the domain name used to access the Owncloud server. The part needs to be changed in the ipadress of the Owncloud server.

server {
 server_name; ### Change this name to your dns name

 listen 443;
 ssl on;
 access_log /var/log/nginx/owncloud.access.log;
 error_log /var/log/nginx/owncloud.error.log;
 ssl_certificate /etc/ssl/nginx/server.crt;
 ssl_certificate_key /etc/ssl/nginx/server.key;

 location / {
 ### Proxy Pass Info ###
 proxy_pass; ###You can change the ipadress with the remote address of your ownclou server if it is not on the same machine, wich is preferred.

 ### Set headers ###
 proxy_set_header Accept-Encoding "";
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 add_header Front-End-Https on;

 ### Options ##
 client_max_body_size 1024M;

 ### Set timeouts ###
 proxy_read_timeout 600s;
 proxy_send_timeout 600s;
 proxy_connect_timeout 600s;

We then will enable the new site configuration by creating a symbolic link in the /etc/nginx/sites-enabled directory.
sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/owncloud

Try the new configuration

Restart the services to load the new configurations

sudo service nginx restart

The Owncloud server should be available now by typing (change in your own name)