text 强制重定向到https nextcloud
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 强制重定向到https nextcloud相关的知识,希望对你有一定的参考价值。
WARNING
DO NOT REPLACE ALL YOUR FILES BY THE FOLLOWING SNIPPETS
Backup
first a backup of the current .htaccess and signature.json :
cp .htaccess .htaccess.bak
cp core/signature.json core/signature.json.bak
.htaccess
We are gonna add those 2 lines after RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Get SHA512SUM of new version
sha512sum .htaccess
Result
a25b27be52575d88aa83d384de9e55076262041262fbe707b37e30f606d2291ffd094f0f70142aca5d77d3b1e23cdb8045fa1118d7913ac1b0e3bcbc8aac6f9d .htaccess
We only need the checksum which is in my case : a25b27be52575d88aa83d384de9e55076262041262fbe707b37e30f606d2291ffd094f0f70142aca5d77d3b1e23cdb8045fa1118d7913ac1b0e3bcbc8aac6f9d so we're gonna copy it to the file core/signature.json
core/signature.json
Old
{
"hashes": {
".htaccess": "ab5f4c44ba2f9c66f2ed25c3ad3d84660b2808cca11ffa8fe2778a648a054d8ada495a0bf4715dc873aac1efe8dfd92a72f9a24441d8f5240834e639325fd892"
},
"signature": "avHuGdaBjxGen+cMeURgVAPlzvD\/Y495QnzLFG0RLgYKoAR27Uh5iUtPYYQKzbTpGv84dIyq7AyXAoSvowTQs5PAYx1xyBxotl6AN3HM4l32pvxC5H3UdeWtoXybObAy4h7SV0h5HHQm8Re8stKktm5gUCRuD5S0TJ7ESMaUTmnRxnGD4oBS6TUnPSACTINCsaKmcSBG3iV4DiZYdHsnSoVJwZss8MqLHC5\/eCkF8ruUQZFyXiW1931nIbFP9j4JeRfAM1fp58ZDH\/SIP3wn9Axd9Gcz+lf67LB7sr7loaNc77nmEHjQdQ35xkEqrGst2xvgneNg8ncPE863NbqPcg==",
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEojCCA4qgAwIBAgICEAAwDQYJKoZIhvcNAQ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VuLVd1ZXJ0dGVtYmVyZzESMBAGA1UEBwwJU3R1dHRnYXJ0MRcw\r\nFQYDVQQKDA5OZXh0Y2xvdWQgR21iSDEhMB8GA1UEAwwYTmV4dGNsb3VkIFJvb3Qg\r\nQXV0aG9yaXR5ggIQADAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUH\r\nAwEwDQYJKoZIhvcNAQELBQADggEBADZ6+HV\/+0NEH3nahTBFxO6nKyR\/VWigACH0\r\nnaV0ecTcoQwDjKDNNFr+4S1WlHdwITlnNabC7v9rZ\/6QvbkrOTuO9fOR6azp1EwW\r\n2pixWqj0Sb9\/dSIVRpSq+jpBE6JAiX44dSR7zoBxRB8DgVO2Afy0s80xEpr5JAzb\r\nNYuPS7M5UHdAv2dr16fDcDIvn+vk92KpNh1NTeZFjBbRVQ9DXrgkRGW34TK8uSLI\r\nYG6jnfJ6eJgTaO431ywWPXNg1mUMaT\/+QBOgB299QVCKQU+lcZWptQt+RdsJUm46\r\nNY\/nARy4Oi4uOe88SuWITj9KhrFmEvrUlgM8FvoXA1ldrR7KiEg=\r\n-----END CERTIFICATE-----"
}
New
So here we replace the old checksum of .htaccess ONLY with the copied one
We finaly get (in my case) :
{
"hashes": {
".htaccess": "a25b27be52575d88aa83d384de9e55076262041262fbe707b37e30f606d2291ffd094f0f70142aca5d77d3b1e23cdb8045fa1118d7913ac1b0e3bcbc8aac6f9d"
},
"signature": "avHuGdaBjxGen+cMeURgVAPlzvD\/Y495QnzLFG0RLgYKoAR27Uh5iUtPYYQKzbTpGv84dIyq7AyXAoSvowTQs5PAYx1xyBxotl6AN3HM4l32pvxC5H3UdeWtoXybObAy4h7SV0h5HHQm8Re8stKktm5gUCRuD5S0TJ7ESMaUTmnRxnGD4oBS6TUnPSACTINCsaKmcSBG3iV4DiZYdHsnSoVJwZss8MqLHC5\/eCkF8ruUQZFyXiW1931nIbFP9j4JeRfAM1fp58ZDH\/SIP3wn9Axd9Gcz+lf67LB7sr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SLCfPPqtqc0DCBpQYDVR0jBIGd\r\nMIGagBRt6m6qqTcsPIktFz79Ru7DnnjtdKF+pHwwejELMAkGA1UEBhMCREUxGzAZ\r\nBgNVBAgMEkJhZGVuLVd1ZXJ0dGVtYmVyZzESMBAGA1UEBwwJU3R1dHRnYXJ0MRcw\r\nFQYDVQQKDA5OZXh0Y2xvdWQgR21iSDEhMB8GA1UEAwwYTmV4dGNsb3VkIFJvb3Qg\r\nQXV0aG9yaXR5ggIQADAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUH\r\nAwEwDQYJKoZIhvcNAQELBQADggEBADZ6+HV\/+0NEH3nahTBFxO6nKyR\/VWigACH0\r\nnaV0ecTcoQwDjKDNNFr+4S1WlHdwITlnNabC7v9rZ\/6QvbkrOTuO9fOR6azp1EwW\r\n2pixWqj0Sb9\/dSIVRpSq+jpBE6JAiX44dSR7zoBxRB8DgVO2Afy0s80xEpr5JAzb\r\nNYuPS7M5UHdAv2dr16fDcDIvn+vk92KpNh1NTeZFjBbRVQ9DXrgkRGW34TK8uSLI\r\nYG6jnfJ6eJgTaO431ywWPXNg1mUMaT\/+QBOgB299QVCKQU+lcZWptQt+RdsJUm46\r\nNY\/nARy4Oi4uOe88SuWITj9KhrFmEvrUlgM8FvoXA1ldrR7KiEg=\r\n-----END CERTIFICATE-----"
}
Final Tasks
Test
Open you browser and access to your cloud domains without https extensions and normaly it'll redirect you to https.
Delete Backups
rm .htaccess.bak
rm core/signature.json.bak
以上是关于text 强制重定向到https nextcloud的主要内容,如果未能解决你的问题,请参考以下文章
text 在Laravel网站上启用SSL并启用强制HTTPS重定向:https://www.cloudways.com/blog/how-to-setup-https-ssl-certificate