Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
195 views
in Technique[技术] by (71.8m points)

.net - How can I run a https server on Heroku with docker?

I have a .net core 3.1 web api that I wrap in a docker image for release on heroku. As standard, I have enabled HTTPS and redirection from HTTP to HTTPS for my server. It works well as a standalone component, as well as within docker.

The problem arises when Heroku comes into picture. I can reach my application, but it looks like the HTTP port is the one that heroku routers pick and I get naturally a redirection (status 307): 2021-01-28T23:39:23.806237+00:00 heroku[router]: at=info method=GET path="/matches" host=stg-inform-web-api.herokuapp.com request_id=xxx fwd="xxx" dyno=web.1 connect=0ms service=6ms status=307 bytes=192 protocol=https

How am I supposed to deal with this? Is it the case that I don't really need https internally for this infrastructure setting for my server?

question from:https://stackoverflow.com/questions/65947114/how-can-i-run-a-https-server-on-heroku-with-docker

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Heroku takes care of deploying your application, providing a hostname (myapp.herokuapp.com) and SSL (access via HTTPS).
You need to make sure your web application can bind to the port assigned at runtime by Heroku, this is provided in the $PORT env variable.

The web layer is provided by Heroku so your app only need to accept HTTP requests.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...