Generate https links in port 80

Sorry, I’m not following (fully understanding) your posts.

You said,

I need to implement the server so that it listens to port 80 but gives links in https. How can I solve this problem?

If I understand you directly, you want all port 80 HTTP traffic to redirect to port 443 HTTPS and you do not want to send HTTPS traffic on port 80, but only redirect port 80 to port 443.

If so, this is how most every web server is set up; and for example, if you use LetsEncrypt to set up your port 443 traffic using Apache2 or ngnix, LetsEncrypt will ask you if you want to set up this redirect and will do it for you.

As @Falco asked, what is your exact configuration? Are you running a web server like nginx or Apache2 in front of Discourse as a reverse proxy?

If so, when you set up LetsEncrypt on nginx or Apache2, the LetsEncrypt setup software will set up the “redirect all HTTP to HTTPS” for you (if you select “yes” when the configuration dialog asks).