[nginx] Configure HTTPS requests to HTTP

To convert HTTPS requests to HTTP requests, you can add the following configuration to Nginx's configuration file:

  1. Open the Nginx configuration file, usually located at /etc/nginx/nginx.confor /etc/nginx/conf.d/default.conf.

  2. Add the following configuration in serverthe block to forward HTTPS requests to the backend's HTTP service:

server {
    listen 443 ssl;
    server_name yourdomain.com;

    ssl_certificate /path/to/your/ssl_certificate.crt;
    ssl_certificate_key /path/to/your/ssl_certificate.key;

    location / {
        proxy_pass http://backend_server;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Replace yourdomain.comwith your domain name, /path/to/your/ssl_certificate.crtand /path/to/your/ssl_certificate.keywith the path to your SSL certificate and private key.

Replace http://backend_serverthis with the address of your backend HTTP service, which can be an IP address or domain name. In this way, Nginx will forward the received HTTPS request to the backend HTTP service.

  1. Save the configuration file and restart the Nginx service to make the configuration take effect.
sudo service nginx restart

After this configuration, when an HTTPS request accesses Nginx, Nginx will forward the request to the back-end HTTP service and return the HTTP response to the client.

Please note that you must ensure that the backend HTTP service has been started normally and can handle forwarded requests from Nginx. Additionally, ensure that firewall and security group rules allow communication between the Nginx server and backend services.

Guess you like

Origin blog.csdn.net/gao511147456/article/details/132226072