A
A
AntonyKor2017-04-13 14:29:26
linux
AntonyKor, 2017-04-13 14:29:26

How to enable https in nginx?

Greetings! You need to set up https on your home nas. Operating system: openmedia vault. Needed to install owncloud and it requires https. Work with it goes exclusively on the local network with the indication of ip in the address bar. In the tutorials, I found only the setting for the domain

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shvets, 2017-04-13
@Xuxicheta

My nginx config as https proxy

server {
    listen 443;
    server_name owncloud.mydomain.com;
    ssl on;
    ssl_certificate /etc/nginx/ssl/owncloud.mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/owncloud.mydomain.com/privkey.pem;
    
    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload";
    }
}
server {
    listen 80;
    listen [::]:80;
    server_name owncloud.mydomain.com;
    rewrite ^ https://owncloud.mydomain.com$request_uri? permanent;.
}

Owncloud itself runs on Apache on port 8080, access to which from the external network is closed.
The certificates are obtained from letsencrypt and are located in the /etc/nginx/ssl/owncloud.mydomain.com/ folder as specified in the config.
Clients coming over http are wrapped in https
In the local area network, you can use a self-signed certificate. Specify your IP in server_name

N
Nikita Rukavkov, 2017-04-13
@nicosha

Try this solution: https://letsencrypt.org/. Expands in a few clicks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question