400: The Plain HTTP Request Was Sent to HTTPS Port
As you build your web application, you might encounter a scenario where you need to redirect users from one port to another. This is especially common when using the Nginx server, which is widely used for hosting static websites and applications.
Nginx, like other web servers, uses HTTP (Hypertext Transfer Protocol) by default. However, in some cases, you might need to redirect users from an HTTPS port (port 443) to an HTTP port (port 80). This is because the URL scheme is different between HTTPS and HTTP.
To achieve this redirection, you can use Nginx's built-in server_alias directive. Here is an example of how to set it up:
server {
listen 443 ssl;
server_name example.com;
location / {
proxy_pass http://example.com:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Here's a breakdown of the code:
- listen 443 ssl: This line tells Nginx to listen on port 443, which is typically used for HTTPS.
- server_name example.com;: This sets the server name to "example.com", which will be used in the proxy pass.
- location / {: This line defines a new location block that will handle requests to the root URL of your website.
- proxy_pass http://example.com:80;: This line proxies any incoming request to port 80 on the "example.com" server, effectively forwarding them to your static website or application.
- proxy_set_header Host $host;: This line sets the 'Host' header of the proxied request to the client's IP address.
- proxy_set_header X-Real-IP $remote_addr;: This line sets the 'X-Real-IP' header of the proxied request to the client's IP address.
http://apocalypse.moy.su/go?http://spicy1.blob.core.windows.net/plumber-adelaide/plumber-adelaide/plumber-adelaide.html