Search code examples
sslnginxproxyowncloudnextcloud

Reverse proxy in nginx for nextcloud?


How do I set a reverse proxy for nextcloud? This is my current config but it doesn't work:

server {
  listen 8000;
  server_name cloud.prjctdesign.com;
  return 301 https://$host$request_uri;
}

server {
  listen 4430 ssl http2;
  server_name cloud.prjctdesign.com;

  ssl_certificate /certs/cloud.prjctdesign.com.crt;
  ssl_certificate_key /certs/cloud.prjctdesign.com.key;

  include /etc/nginx/conf/ssl_params.conf;

  client_max_body_size 10G; # change this value it according to $UPLOAD_MAX_SIZE

  location / {
    proxy_pass http://192.168.178.32;
    include /etc/nginx/conf/proxy_params;
  }
}

Also I enabled SSL using a let's encrypt cert. I run Nextcloud in the official VM image provided by Nextcloud / Techandme

I believe there is something wrong with the HSTS but I have no idea how it works. Also I based my forwarding off of this


Solution

  • I figured it out. The reference to the ssl certificate is incorrect. Either run NGINX on the same server you are running nextcloud and redirect nginx to the position of the .cert file as in these lines:

     ssl_certificate /certs/cloud.prjctdesign.com.crt;
     ssl_certificate_key /certs/cloud.prjctdesign.com.key;
    

    or generate a new cert on the nginx server and point the config towards it.