Dear Kindly NC Community
I’m a newbie deploying NC and just deploy NC 21.X on Ubuntu 20.X but I have problem when redirect HTTP into HTTPS mode.
Where script I should modify/put so I can redirect HTTP to HTTPS.
Where the directory path are I have to edited ? ex: /etc/www/nextcloud/???/Files ???
to put this code :
Redirect all unencrypted traffic to HTTPS
<VirtualHost *:80>
ServerName cloud.nextcloud.com
Redirect permanent / https://cloud.nextcloud.com/
Enable HTTP Strict Transport Security
<VirtualHost *:443>
ServerName cloud.nextcloud.com
Header always set Strict-Transport-Security “max-age=15552000; includeSubDomains”
Thank You for your help guys…
Hi @arif_setiawan, your nextcloud server is accessible from WAN ? ( from outside of your network)
If yes you can use certbot to setup https. if not there is many tutorial to set https manually.
The proprest way in my oppinion is to make it accessable form WAN and use the certbot.
1 Like
I use the following code in my setup
<VirtualHost *:80>
ServerName myweb.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www
# La etiqueta env=!dontlog es una variable para que no se registren esos accesos:
SetEnvIf Request_URI "^/page1/data.json*" dontlog
SetEnvIf Request_URI "^/page2" dontlog
SetEnvIf Request_URI "^/apple-touch-icon-*" dontlog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
# Redirecciona todo de HTTP a HTTPS excepto:
RewriteEngine On
RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} !^/page1/index3.html
RewriteCond %{REQUEST_URI} !^/page2/data.json
RewriteCond %{REQUEST_URI} !^/page3/.*
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>