How to automatically redirect HTTP traffic to HTTPS


#1

I have successfully setup gogs on HTTPS, but whenever I accidentally try to connect on non-secure HTTP, it throws an error (as expected). Is there any way to automatically redirect those accidental calls on HTTP port to the HTTPS port?

I’m hoping to do this within the existing gogs binary, without the need to stand up another web server just to catch the HTTP requests and redirect that way.

I’m running latest build (v0.11.53) on Winx64 from binary package.


#2

try to https://www.linode.com/docs/development/version-control/install-gogs-on-debian/#disable-http-access-to-gogs

regards.


#3

@malxhn - I think you misunderstood what I’m looking for. The link you sent is similar to how I have it setup, but what I’m looking for is a simple redirect (Server 301 HTTP status code, etc) when HTTP connections are attempted, and not a connection refusal.

Here’s roughly what I’m talking about:
Connection Port -> Desired action by GOGS


HTTP_PORT -> Respond with redirect to HTTPS_PORT
HTTPS_PORT -> Serve up GOGS application as configured (SSL secured)


#4

Hi, do it with reverse proxy (e.g. IIS), Gogs itself does not handle/care such … feature.


#5

OK, that’s what I figured I might end up having to do. I was just hoping it might be included in GOGS to avoid setting up a secondary proxy/redirect server just for that purpose.

Thanks