trusted SSL certificate<\/a>.<\/p>\r\n\r\n\r\n\r\nNext, create a new Nginx server block:<\/p>\r\n\r\n\r\n\r\n
[user]$ sudo nano \/etc\/nginx\/sites-available\/nextcloud<\/pre>\r\n\r\n\r\n\r\nserver {\r\n listen 80;\r\n server_name my.nextcloud.com;\r\n return 301 https:\/\/$server_name$request_uri;\r\n}\r\nserver {\r\n listen 443 ssl http2;\r\n server_name my.nextcloud.com;\r\n root \/var\/www\/nextcloud;\r\n\r\n ssl on;\r\n ssl_certificate \/etc\/nginx\/ssl\/nextcloud.crt;\r\n ssl_certificate_key \/etc\/nginx\/ssl\/nextcloud.key;\r\n ssl_session_timeout 5m;\r\n ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';\r\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\r\n ssl_prefer_server_ciphers on;\r\n\r\n add_header X-Content-Type-Options nosniff;\r\n add_header X-Frame-Options \"SAMEORIGIN\";\r\n add_header X-XSS-Protection \"1; mode=block\";\r\n add_header X-Robots-Tag none;\r\n add_header X-Download-Options noopen;\r\n add_header X-Permitted-Cross-Domain-Policies none;\r\n\r\n access_log \/var\/log\/nginx\/nextcloud.access.log;\r\n error_log \/var\/log\/nginx\/nextcloud.error.log;\r\n\r\n location = \/robots.txt {\r\n allow all;\r\n log_not_found off;\r\n access_log off;\r\n }\r\n\r\n location = \/.well-known\/carddav { \r\n return 301 $scheme:\/\/$host\/remote.php\/dav; \r\n }\r\n location = \/.well-known\/caldav { \r\n return 301 $scheme:\/\/$host\/remote.php\/dav; \r\n }\r\n\r\n client_max_body_size 512M;\r\n fastcgi_buffers 64 4K;\r\n gzip off;\r\n\r\n error_page 403 \/core\/templates\/403.php;\r\n error_page 404 \/core\/templates\/404.php;\r\n\r\n location \/ {\r\n rewrite ^ \/index.php$uri;\r\n }\r\n\r\n location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {\r\n deny all;\r\n }\r\n\r\n location ~ ^\/(?:\\.|autotest|occ|issue|indie|db_|console) {\r\n deny all;\r\n }\r\n\r\n location ~^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|core\/templates\/40[34])\\.php(?:$|\/) {\r\n include fastcgi_params;\r\n fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n fastcgi_param PATH_INFO $fastcgi_path_info;\r\n fastcgi_param HTTPS on;\r\n #Avoid sending the security headers twice\r\n fastcgi_param modHeadersAvailable true;\r\n fastcgi_param front_controller_active true;\r\n fastcgi_pass unix:\/var\/run\/php\/php7.0-fpm.sock;\r\n fastcgi_intercept_errors on;\r\n fastcgi_request_buffering off;\r\n }\r\n\r\n location ~ ^\/(?:updater|ocs-provider)(?:$|\/) {\r\n try_files $uri\/ =404;\r\n index index.php;\r\n }\r\n\r\n location ~* \\.(?:css|js)$ {\r\n try_files $uri \/index.php$uri$is_args$args;\r\n add_header Cache-Control \"public, max-age=7200\";\r\n add_header X-Content-Type-Options nosniff;\r\n add_header X-Frame-Options \"SAMEORIGIN\";\r\n add_header X-XSS-Protection \"1; mode=block\";\r\n add_header X-Robots-Tag none;\r\n add_header X-Download-Options noopen;\r\n add_header X-Permitted-Cross-Domain-Policies none;\r\n # Optional: Don't log access to assets\r\n access_log off;\r\n }\r\n\r\n location ~* \\.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {\r\n try_files $uri \/index.php$uri$is_args$args;\r\n access_log off;\r\n }\r\n\r\n location ~ \/\\.ht {\r\n deny all;\r\n }\r\n\r\n}<\/pre>\r\n\r\n\r\n\r\nActivate the server block by creating a symbolic link :<\/p>\r\n\r\n\r\n\r\n
[user]$ sudo ln -s \/etc\/nginx\/sites-available\/nextcloud \/etc\/nginx\/sites-enabled\/nextcloud<\/pre>\r\n\r\n\r\n\r\nTest the Nginx configuration and restart nginx:<\/p>\r\n\r\n\r\n\r\n
[user]$ sudo nginx -t\r\n[user]$ sudo service nginx restart<\/pre>\r\n\r\n\r\n\r\n