Hello all,

Is there any way to load http contents over https while enabling ssl?

Many thanks

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.

×
1 answer

Hi @myahya,

I’m not entirely sure I understand the question, you want to serve the resources of your website via http while loading https, is that correct?

Can you please provide a little bit more information, may be an example will help?

Regards,
KFSys

  • Hello KFSys,

    Inside my app, I’m setting using the ws endpoint like this:

    const web3 = new Web3 ('ws://server-ip:7546')
    

    Note: I can’t use const web3 = new Web3 (‘wss://server-ip:7546’)

    I have updated Nginx configs like this to proxy the above-mentioned ws endpoint:

    server {
               listen 443;
               server_name my.app.com;
    
               root /home/ubuntu/app;
               index index.html;
    
               ssl_certificate /etc/letsencrypt/live/fullchain.pem;
               ssl_certificate_key /etc/letsencrypt/live/privkey.pem; 
               include /etc/letsencrypt/options-ssl-nginx.conf; 
               ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    
               ssl on;
               ssl_session_cache  builtin:1000  shared:SSL:10m;
    
    
            location / {
    
               proxy_pass http://server-ip:7546;
    
               proxy_http_version 1.1;
               proxy_set_header Upgrade $http_upgrade;
               proxy_set_header Connection "Upgrade";
               proxy_set_header Host $host;
    
            }
    
        }
    

    I’m using the same server-ip in my app and proxy_pass.

    The error is:
    ** Mixed Content: The page was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint.

    any help what I’m doing wrong here?

    • To my knowledge, it is impossible to make browser run http content with https. I have encountered this error in the past. And I had to switch from ws:// to wss://. I think your current nginx configuration works for both ws:// and wss://. You just need to change ws:// to wss:// inside your app.

    • The Mixed Content error is usually related to your application rather than your WebService’s configuration.

      You should look into your code and make all media like css, images etc. to be served via HTTPS rather than HTTP.

      • Hello @KFSys,

        Thank you for your support.

        The problem is only with ws configuration, the rest of the application is working fine.

        Mixed Content: The page was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint.
        

        All the media is being served on https.

        Regards,
        Yahya

Submit an Answer