lemmy.world should redirect to https (secure) site

3 years ago by overby to c/lemmyworld

ruud 7 points 3 years ago

Yes that’s on my to do list. I’ll do that today.

path: 0 29509, hotness: undefined, score: 7, children: 0
WhoRoger 6 points 3 years ago

Don't all modern browsers try https by default?

(Not that I disagree.)

path: 0 28847, hotness: undefined, score: 6, children: 1
animist 2 points 3 years ago

Every time I set up FF on a new install I have to choose always on https

path: 0 28847 29318, hotness: undefined, score: 2, children: 0
ruud 4 points 3 years ago

Hmm , when I replace this:

http {
  server {
    listen 80;
    server_name lemmy.world;

    location / {
        proxy_pass http://lemmy-ui:1234;
        proxy_set_header Host $host;
    }
}

with this:

http {
  server {
    listen 80;
    server_name lemmy.world;

    location / {
        return 301 https://$host$request_uri;
    }
}

it breaks, gives 502 when visiting the site...

ideas? (I'm not that much into nginx...)

path: 0 30629, hotness: undefined, score: 4, children: 6
lemann 3 points 3 years ago

You could try this

this config snippet is assuming thet you've already got the TLS cert/pem file for lemmy.world elsewhere in your nginx.config

http {
  server {
    listen 80;
    listen 443 ssl;
    server_name lemmy.world;

    if ($scheme = "http") {
        return 307 https://$host$request_uri;
    }

    location / {
        proxy_pass http://lemmy-ui:1234;
        proxy_set_header Host $host;
    }
}

If you get redirected to lemmy.world:1234, then add absolute_redirect off; in the 'server' block

Last thing - 307 is a temporary redirect, you might to change it to a permanent one once you've confirmed it's working as intended

path: 0 30629 32122, hotness: undefined, score: 3, children: 1
ruud 2 points 3 years ago

Cool, thanks! I'll try that.

path: 0 30629 32122 32154, hotness: undefined, score: 2, children: 0
Tom 1 point 3 years ago
path: 0 30629 34036, hotness: undefined, score: 1, children: 0
slashzero 1 point 3 years ago

You might want to add the secure port (:443) in your redirect. Otherwise it might be trying to load https on port 80 still, which can’t work.

  • http: port 80
  • https: port 443

Notes:

  • just a guess. I haven’t looked at an nginx config in a while
  • make sure to try on multiple browsers as they all don’t behave the same way
path: 0 30629 32184, hotness: undefined, score: 1, children: 2
ruud 1 point 3 years ago

This piece I've pasted above isn't the whole nginx.conf, there's also a large block for the 443 traffic. It's just the http traffic that I need to redirect to 443.

path: 0 30629 32184 32243, hotness: undefined, score: 1, children: 1
slashzero 1 point 3 years ago

Ok. Now that I think about it, you shouldn’t have to specify the port.

path: 0 30629 32184 32243 32428, hotness: undefined, score: 1, children: 0
CannaVet 3 points 3 years ago

I've been on the secure version by default so far myself.

path: 0 31456, hotness: undefined, score: 3, children: 2
ruud 2 points 3 years ago

Yes most browsers automatically do, but some don't..

path: 0 31456 31514, hotness: undefined, score: 2, children: 1
CannaVet 1 point 3 years ago

Oooh I thought it was a backend thing, cause my NGINX has a force SSL option. I guess it can be done from either end.

path: 0 31456 31514 31577, hotness: undefined, score: 1, children: 0
ruud 3 points 3 years ago

I think I now fixed it

path: 0 62920, hotness: undefined, score: 3, children: 2
ruud 1 point 3 years ago path: 0 62920 63112, hotness: undefined, score: 1, children: 1
ruud 1 point 3 years ago

Ooh it worked!

path: 0 62920 63112 63121, hotness: undefined, score: 1, children: 0
Tom 2 points 3 years ago
path: 0 33920, hotness: undefined, score: 2, children: 0
lemmyworld
lemmyworld

@lemmy.world

login for more options
31472
771
649

This Community is intended for posts about the Lemmy.world server by the admins.

Follow us for server news 🐘

Outages 🔥

https://status.lemmy.world

For support with issues at Lemmy.world, go to the Lemmy.world Support community.

Support e-mail

Any support requests are best sent to info@lemmy.world e-mail.

Report contact

Donations 💗

If you would like to make a donation to support the cost of running this platform, please do so at the following donation URLs.

If you can, please use / switch to Ko-Fi, it has the lowest fees for us

Ko-Fi (Donate)

Bunq (Donate)

Open Collective backers and sponsors

Patreon

Join the team

go to feed...