51
submitted 3 years ago by Gamera8ID@lemm.ee to c/selfhosted@lemmy.world

Today I decided to get an inexpensive custom domain from Namecheap and try self-hosting Lemmy. A few bucks later I was thinking, "Hey, this is going to be cake."

I'd read some of the warnings about Oracle Cloud free tier, but figured I'd still give it a shot for hosting. I found a simple how-to for quickly getting an Ubuntu instance spun up with Docker and Portainer. A few minutes later I'm thinking, "This is so easy!"

Then I try to access Portainer using HTTPS and see my first "Your connection is not private," warning. "No worries," I think. "Advanced>Proceed. I'm in."

So I run Lemmy Easy Deploy. "The lights are green, the trap is clean! Boom. Here we go!"

Nothing.

Ports seem to be open on Oracle, but no Lemmy at either 80 or 443.

"Maybe Lemmy is more particular about SSL certificates and such?" I think, for the first time getting worried.

"Err, I think that if I change my nameserver to Cloudflare I can destroy my Lemmy containers, re-run Lemmy Easy Deploy with a Cloudflare API token, and maybe fix it?

Four hours later, after repeatedly starting over, clearing my browser cache every 5 minutes, switching back and forth between nameservers, even deleting the whole Oracle Cloud VM and starting from scratch, I realize that an HTTP connection to port 443 is returning "Client sent an HTTP request to an HTTPS server."

"Were you there before, message?" I wonder.

Lemmy friends, can you help me? Or am I better off just deleting the VM and giving up the whole idea?

you are viewing a single comment's thread
view the rest of the comments
[-] SheeEttin@lemmy.world 2 points 3 years ago

That sounds more like your browser, not caddy.

[-] 4am@lemmy.world 3 points 3 years ago

No, most browsers will do what they’re told. At least with nginx, you have to set up a server to listen on port 80 and send a 301 permanently redirected message with the https URL.

[-] pe1uca@lemmy.pe1uca.dev 2 points 3 years ago

Ah, maybe I wasn't clear enough, caddy doesn't need a configuration to redirect traffic from port 80 to port 443, it does it automatically: https://caddyserver.com/docs/automatic-https

If you want to configure an http only site you need to specifically configure it in your Caddyfile.
Here's an example for a reverse proxy

# We don't specify the protocol so Caddy assumes HTTPS and redirects any HTTP to secure.  
secure.example.com { reverse_proxy :<port> }

# HTTP is specified so Caddy won't redirect to port 443 nor generate a certificate.  
http://insecure.example.com { reverse_proxy :<port> }
[-] SheeEttin@lemmy.world 1 points 3 years ago

Yeah, I figured that's what you meant after rereading it. Chrome at least does automatically switch to HTTPS in some cases, like where it's seen HSTS.

this post was submitted on 06 Jul 2023
51 points (100.0% liked)

Selfhosted

60910 readers
764 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

Detailed Rules Post

  1. Be civil.

  2. No spam.

  3. Posts are to be related to self-hosting.

  4. Don't duplicate the full text of your blog or readme if you're providing a link.

  5. Submission headline should match the article title.

  6. No trolling.

  7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

  8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 3 years ago
MODERATORS