Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sutty nginx config #96

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Sutty nginx config #96

wants to merge 9 commits into from

Conversation

fauno
Copy link
Collaborator

@fauno fauno commented Dec 7, 2024

hyphacoop/distributed-press-organizing#155

most are safety options but the tls config and gzip pre compression are performance optimizations too. i didn't add the brotli_static because debian doesn't seem to have it for nginx

edit: also caching

@fauno fauno requested a review from RangerMauve December 7, 2024 16:55
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header 'X-Frame-Options' 'ALLOW-FROM *';
add_header X-Frame-Options "sameorigin";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to allow iframes for sites by default

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only forbids the site to be iframed elsewhere (like a malicious site hijacking clicks)

ansible/roles/distributed_press/templates/nginx-static.j2 Outdated Show resolved Hide resolved
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header 'X-Frame-Options' 'ALLOW-FROM *';
add_header X-Frame-Options "sameorigin";
add_header X-XSS-Protection "1; mode=block";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to support XSS for stuff like p2p web apps

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes!

add_header X-Frame-Options "sameorigin";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header Referrer-Policy "strict-origin-when-cross-origin";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referrer could be good for our analytics when users navigate to DP from the thing in the footer, is there a way to support that still?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will instruct browsers to set the referer only to the origin if the destination is secure, so third party websites can know from where the visit came from but not the particular page

@@ -12,26 +12,36 @@ server {

error_page 404 /404.html;

add_header Cache-Control no-cache;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no cache?

Copy link
Collaborator Author

@fauno fauno Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want caches to always check for content updates while reusing stored content, no-cache is the directive to use. It does this by requiring caches to revalidate each request with the origin server.

Note that no-cache does not mean "don't cache". no-cache allows caches to store a response but requires them to revalidate it before reuse. If the sense of "don't cache" that you want is actually "don't store", then no-store is the directive to use.

source

in practice since nginx is adding etag headers to every static file, it'll return 304 for cached urls so you save the body bytes, but still need an open connection to the webserver. it's a better alternative than guessing how long you need to cache and get asked why a very very very recent change doesn't show up yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i made edits to the above comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants