# Security: \_\_Host-Prefix cookie setting?

**URL:** <https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740>\
**Category:** ℹ️ Support\
**Created:** [March 6, 2017, 10:56am UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740 "2017-03-06T10:56:16Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oclair](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oclair/32/2198_2.png) [@Oclair](https://help.nextcloud.com/u/Oclair)\
**Post date:** [March 6, 2017, 10:56am UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/1 "2017-03-06T10:56:16Z")

</div>

Anyone know of a doc to explain enabling \_\_Host-Prefix?

My [https://scan.nextcloud.com](https://scan.nextcloud.com) indicates it’s the only step left to do  
note: FreeBSD 11.0 p8

Thanks in advance for any ideas on this!!  
OC

\_\_Host-Prefix may be something so new that the nextcloud docs are not yet up for it, I only found it mentioned on Github and the nextcloud blog

[https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) indicates a spec for \_\_Host- prefix other than that it’s really not documented out there…

Security and Nextcloud 9 Jun 14, 2016 [https://statuscode.ch/2016/06/security-and-nextcloud-9/](https://statuscode.ch/2016/06/security-and-nextcloud-9/) mentions same-site cookies

---

<div class="post-metadata">

**Author:** ![JoMatr](https://help.nextcloud.com/letter_avatar/jomatr/32/6_449c533f586939b6e5f246632a46421f.png) [@JoMatr](https://help.nextcloud.com/u/JoMatr)\
**Post date:** [March 6, 2017, 2:11pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/2 "2017-03-06T14:11:32Z")

</div>

Same Question here. Everything fine, scan gives grade A, only thing is \_\_Host-Prefix ??  
Server: Debian Jessie, php 7.0.16, mysql 5.5.54, apache 2.4.10

---

<div class="post-metadata">

**Author:** ![FredFS456](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fredfs456/32/573_2.png) [@FredFS456](https://help.nextcloud.com/u/FredFS456)\
**Post date:** [March 6, 2017, 2:13pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/3 "2017-03-06T14:13:19Z")

</div>

Same question here. I’m guessing it’s automagically enabled when the environment supports it, but a quick google can’t find anything about which part of my environment is unsupported.

Nextcloud 11.0.2  
PHP 5.6.30  
Apache 2.4.10  
MariaDB 10.0.29  
Debian 8.7

---

<div class="post-metadata">

**Author:** ![xaasst](https://help.nextcloud.com/letter_avatar/xaasst/32/6_449c533f586939b6e5f246632a46421f.png) [@xaasst](https://help.nextcloud.com/u/xaasst)\
**Post date:** [March 6, 2017, 2:17pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/4 "2017-03-06T14:17:12Z")

</div>

Hi,

same here. Would be nice to know where the problem might be.

---

<div class="post-metadata">

**Author:** ![LukasReschke](https://help.nextcloud.com/user_avatar/help.nextcloud.com/lukasreschke/32/1929_2.png) [@LukasReschke](https://help.nextcloud.com/u/LukasReschke)\
**Post date:** [March 6, 2017, 2:23pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/5 "2017-03-06T14:23:42Z")

</div>

Hey there

This one should be applied automatically if the following conditions are met:

- Nextcloud is accessible via HTTPS
- Nextcloud is not installed in a subfolder (e.g. [cloud.foo.com](http://cloud.foo.com) not [cloud.foo.com/nextcloud/](http://cloud.foo.com/nextcloud/))

Note that this is only a “hardening” but not a security vulnerability per se. So if you don’t manage to have it: It won’t make your data insecure, but having it is an easy small security gain 🙂

Can you check if those conditions are met for you? If yes and the setting isn’t applied this could be a bug or a misconfiguration in your setup. Send me a PM with your domain then please and I can check that 🙂

Cheers  
Lukas

---

<div class="post-metadata">

**Author:** ![Schmu](https://help.nextcloud.com/user_avatar/help.nextcloud.com/schmu/32/7823_2.png) [@Schmu](https://help.nextcloud.com/u/Schmu)\
**Post date:** [March 6, 2017, 2:31pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/6 "2017-03-06T14:31:02Z")

</div>

Hi @LukasReschke

I guess the second point explains it for me. I have  
`https://mydomain.net/nextcloud`  
(`/var/www/nextcloud/`)

But why doesn’t it work with subfolders and is there a way to enable \_\_Host-Prefix anyway? If I have to get rid of the subfolder, does it mean I have to move  
`/var/www/nextcloud/` to  
`/var/www/`

or do I have to do something else?

Thanks a lot

---

<div class="post-metadata">

**Author:** ![LukasReschke](https://help.nextcloud.com/user_avatar/help.nextcloud.com/lukasreschke/32/1929_2.png) [@LukasReschke](https://help.nextcloud.com/u/LukasReschke)\
**Post date:** [March 6, 2017, 3:07pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/7 "2017-03-06T15:07:18Z")

</div>

> [@Schmu](#):
>
> But why doesn’t it work with subfolders and is there a way to enable \_\_Host-Prefix anyway? If I have to get rid of the subfolder, does it mean I have to move/var/www/nextcloud/ to/var/www/
> 
> or do I have to do something else?
> 
> Thanks a lot

As per specification [https://tools.ietf.org/html/draft-ietf-httpbis-cookie-prefixes-00](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-prefixes-00) :

If a cookie’s name begins with “\_\_Host-”, the cookie MUST be:

1. Set with a “Secure” attribute
2. Set from a URI whose “scheme” is considered “secure” by the user  
agent.
3. Sent only to the host which set the cookie. That is, a cookie  
named “\_\_Host-cookie1” set from “[https://example.com](https://example.com)” MUST NOT  
contain a “Domain” attribute (and will therefore be sent only to  
“[example.com](http://example.com)”, and not to “[subdomain.example.com](http://subdomain.example.com)”).
4. Sent to every request for a host. That is, a cookie named  
“\_\_Host-cookie1” MUST contain a “Path” attribute with a value of  
“/”.

As per item 4 this means that we cannot do much here. That said, not having this security hardening doesn’t put you at risk. But it is something that you can consider for a future deployment.

If you really want to have an A+ rating here the easiest way would be to change the DocumentRoot in the apache configuration. However, all your connected clients would need to be reconnected and sharing links would stop working.

---

<div class="post-metadata">

**Author:** ![nursoda](https://help.nextcloud.com/user_avatar/help.nextcloud.com/nursoda/32/1044_2.png) [@nursoda](https://help.nextcloud.com/u/nursoda)\
**Post date:** [March 6, 2017, 5:47pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/8 "2017-03-06T17:47:18Z")

</div>

Thanks. So, I will not get an A+ due to having it installed in a subdir (which I consider perfectly fine) ;-/

Since this will hit many users, you should link to this thread or some other FAQ in the scan results.

---

<div class="post-metadata">

**Author:** ![nextcloud-comment2](https://help.nextcloud.com/letter_avatar/nextcloud-comment2/32/6_449c533f586939b6e5f246632a46421f.png) [@nextcloud-comment2](https://help.nextcloud.com/u/nextcloud-comment2)\
**Post date:** [March 6, 2017, 6:06pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/9 "2017-03-06T18:06:48Z")

</div>

@LukasReschke so the rating considers a nextcloud installtion more secure, if it runs directly in the root of a webserver where the crawlers find it, instead of running it in a “hidden” subdirectory?

---

<div class="post-metadata">

**Author:** ![Schmu](https://help.nextcloud.com/user_avatar/help.nextcloud.com/schmu/32/7823_2.png) [@Schmu](https://help.nextcloud.com/u/Schmu)\
**Post date:** [March 6, 2017, 6:09pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/10 "2017-03-06T18:09:14Z")

</div>

Re-reading what @LukasReschke wrote and re-checking my configuration, I’m coming to think that the issue is not the folder in which we placed our nextcloud installation but rather the subdomain.  
I just realized that although having NC installed in  
`/var/www/nextcloud/`

it reads  
`https://cloud.mydomain.net/index.php`

So I guess it meets the criteria for `path="/"`.  
However he also mentions that there can’t be a sub-domain. And maybe someone can help with that, because I’m pretty new to web servers and cloud and stuff:  
How can I achieve not having NC under a sub-domain?

I rent a domain at [1und1.de](http://1und1.de) and while I don’t have a static IP address I think I had to create a sub-domain and enter the My-Fritz URL (like [dyndns.org](http://dyndns.org)) as CNAME.  
As said, being a newbie, what can I do different to get the A+?

Every advise and detailed explanation by the experienced users is very welcome and really appreciated.

Hm, even the hardening guide ([https://docs.nextcloud.com/server/11/admin\_manual/configuration\_server/harden\_server.html](https://docs.nextcloud.com/server/11/admin_manual/configuration_server/harden_server.html)) advised:

> **Use a dedicated domain for Nextcloud**

> Administrators are encouraged to install Nextcloud on a dedicated domain such as cloud.domain.tld instead of domain.tld to gain all the benefits offered by the Same-Origin-Policy.

---

<div class="post-metadata">

**Author:** ![Lox](https://help.nextcloud.com/user_avatar/help.nextcloud.com/lox/32/881_2.png) [@Lox](https://help.nextcloud.com/u/Lox)\
**Post date:** [March 6, 2017, 7:39pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/11 "2017-03-06T19:39:55Z")

</div>

> [@nursoda](#):
>
> Thanks. So, I will not get an A+ due to having it installed in a subdir (which I consider perfectly fine) ;-/
> 
> Since this will hit many users, you should link to this thread or some other FAQ in the scan results.

👆 this

---

<div class="post-metadata">

**Author:** ![Oclair](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oclair/32/2198_2.png) [@Oclair](https://help.nextcloud.com/u/Oclair)\
**Post date:** [March 6, 2017, 9:39pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/12 "2017-03-06T21:39:46Z")

</div>

This is a bogus security suggestion. Always link a cloud to another subdirectory where search engines do not pry! I give the nextcoud security checker an A- for suggesting it is more secure to host the cloud on the root of a published DNS entry!

---

<div class="post-metadata">

**Author:** ![Oclair](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oclair/32/2198_2.png) [@Oclair](https://help.nextcloud.com/u/Oclair)\
**Post date:** [March 6, 2017, 9:44pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/13 "2017-03-06T21:44:40Z")

</div>

this is a less secure decision not a more secure one  
[http://searchdns.netcraft.com/?restriction=site+contains&host=nextcloud.com&lookup=wait](http://searchdns.netcraft.com/?restriction=site+contains&host=nextcloud.com&lookup=wait)…&position=limited

Another method reveals

Subdomain IP address Netname (whois) Country (whois)  
[lists.nextcloud.com](http://lists.nextcloud.com) 88.198.160.136 HOS-2580 DE  
[projects.nextcloud.com](http://projects.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[conf.nextcloud.com](http://conf.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[updates.nextcloud.com](http://updates.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[apps.nextcloud.com](http://apps.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[docs.nextcloud.com](http://docs.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[download.nextcloud.com](http://download.nextcloud.com) 88.198.160.133 HOS-2580 DE  
[www.nextcloud.com](http://www.nextcloud.com) 88.198.160.129 HOS-2580 DE  
[logs.nextcloud.com](http://logs.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[stats.nextcloud.com](http://stats.nextcloud.com) 88.198.160.129 HOS-2580 DE  
[scan.nextcloud.com](http://scan.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[support.nextcloud.com](http://support.nextcloud.com) 88.198.160.138 HOS-2580 DE  
[mx.nextcloud.com](http://mx.nextcloud.com) 88.198.160.131 HOS-2580 DE  
[demo.nextcloud.com](http://demo.nextcloud.com) 91.103.114.57 ? ?

---

<div class="post-metadata">

**Author:** ![NeptuneUK](https://help.nextcloud.com/letter_avatar/neptuneuk/32/6_449c533f586939b6e5f246632a46421f.png) [@NeptuneUK](https://help.nextcloud.com/u/NeptuneUK)\
**Post date:** [March 13, 2017, 8:23am UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/14 "2017-03-13T08:23:48Z")

</div>

Just thought I would add my A+ rating solution here in case others have a similar setup to myself. I found this thread when I used the Nextcloud scanner and achieved an ‘A’ rating, good, but no cigar! I was presented with the \_\_Host-Prefix issue and the fact that the scanner detected my installation was in a sub-folder (/owncloud), which it wasn’t, it was being served from [https://mynonwww.domain.co.uk](https://mynonwww.domain.co.uk). In addition I was running NC 11.0.1.

I did much searching around without much success for the \_\_Host-Prefix issue solution. In the end it was simple. Upgrading to 11.0.2 fixed the \_\_Host-Prefix issue.

As for the NC installation in a sub-folder. I had migrated from OC9 to NC. After some searching around in my apache config I discovered I had a legacy owncloud.conf file in /etc/apache2/conf-available/. This in turn contained a directory alias for a /owncloud /var/my/OC-NC-installation. As this was not in use, I simply removed the alias from the owncloud.conf file (I’m confident this conf file can be removed safely in the long-term for most migrated installations (just rename it to something else like owncloud.conf.[date])).

Re-ran the NC scanner…A+ rating.

I hope this helps someone else who has a similar setup.

Those looking to get an overall measure of how their server security is stacking up might want to also use:

> **[Analyse your HTTP response headers](https://securityheaders.io/)**
>
> Quickly and easily assess the security of your HTTP response headers

  
and  
[https://www.ssllabs.com/ssltest/](https://www.ssllabs.com/ssltest/)

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_449c533f586939b6e5f246632a46421f.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [April 2, 2017, 11:05am UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/15 "2017-04-02T11:05:40Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 9, 2024, 1:17pm UTC](https://help.nextcloud.com/t/security---host-prefix-cookie-setting/9740/16 "2024-12-09T13:17:48Z")

</div>


