Question

How to proxy https to http and enable ssl?

Hello everyone,

I have configured an app that communicated via websocket (ws) protocol. I want to config this app over https but getting “mixed content error”:

** The app was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint.

Now I want to proxy https to http while enabling the SSL as well.

My current configs are:

server {
           listen 443;
           server_name verify.flexibilitaetsmarkt.de;

            ssl_certificate /etc/letsencrypt/live/verify.flexibilitaetsmarkt.de/fullchain.pem; # managed by Certbot
            ssl_certificate_key /etc/letsencrypt/live/verify.flexibilitaetsmarkt.de/privkey.pem; # managed by Certbot
            include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
         
           ssl on;
           ssl_session_cache  builtin:1000  shared:SSL:10m;

        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            

            proxy_pass http://127.0.0.1:8000;
            proxy_read_timeout 86400;       
         
        }
    }



server {
	listen 8000;
       
	root /home/ubuntu/alf_poc/app;
	# Add index.php to the list if you are using PHP
	index index.html;

}

However, I’m still getting the same error. Is there any help how can I proxy/redirect https to http and enable SSL as well?

Many thanks

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @myahya,

As per the official Nginx documentaton, what I could suggest trying is to add the following extra proxy rules:

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

After that run a config test:

  1. sudo nginx -t

And if you get Syntax OK, restart Nginx:

  1. sudo systemctl restart nginx

Let me know how it goes! Regards, Bobby