I am trying to set up Https for my Ubuntu server using Nginx. I am running an application on localhost and using reverse proxy. This is my first time using Linux and nginx. My https request is failing everytime. I will try to include as many relevant details from the server:
I have assigned a domain name to my site and have configured the ssl certificates using certbot.
When I make a request using http, it is successful: curl request to http port
However, https requests always fail: curl request to https port
Both ports 443 and 80 are active and listening: active ports
In order to make debugging simple I have now configured nginx to redirect http requests(port 80) to https (port 443). This means requests made to my http now also fail. This is my site's configuration file now: nginx conf file
The following is a snippet of the nginx debug log after I made an https request:
2024/12/28 18:27:40 [debug] 21424#21424: *207 http script copy: "https://" 2024/12/28 18:27:40 [debug] 21424#21424: *207 http script var: "chatbot.sweatsupport.site" 2024/12/28 18:27:40 [debug] 21424#21424: *207 http script var: "/ws/socket.io/?EIO=4&transport=polling&t=PGEXYJx" 2024/12/28 18:27:40 [debug] 21424#21424: *207 http finalize request: 301, "/ws/socket.io/?EIO=4&transport=polling&t=PGEXYJx" a:1, c:1 2024/12/28 18:27:40 [debug] 21424#21424: *207 http special response: 301, "/ws/socket.io/?EIO=4&transport=polling&t=PGEXYJx" 2024/12/28 18:27:40 [debug] 21424#21424: *207 http set discard body 2024/12/28 18:27:40 [debug] 21424#21424: *207 HTTP/1.1 301 Moved Permanently Server: nginx/1.24.0 (Ubuntu) Date: Sat, 28 Dec 2024 18:27:40 GMT Content-Type: text/html Content-Length: 178 Connection: keep-alive Location: https://chatbot.sweatsupport.site/ws/socket.io/?EIO=4&transport=polling&t=PGEXYJx What I have interpreted from the log is that a 301 http response is made. There seems to be no upstream logs showing any requests to localhost:8000. I do attempt to understand the log but that lead to more confusions so I will not mention that.
I have been stuck on this error for 3 days and have browsed the most forums I could but to no avail. Please do let me know if you need any more information. I would be grateful for any advice.
proxy_pass http://localhost:8000toproxy_pass http://localhostand restart nginx and try again using https? It seems like https connection are redirecting to localhost:8000proxy_pass http://localhostshould be valid. Test itfor 3 daysin that three days, did you test without the proxy? Did it work? Info 101.