vkuznecovas / mouthful

Mouthful is a self-hosted alternative to Disqus
https://mouthful.dizzy.zone/
MIT License
762 stars 37 forks source link

Embedding inside an https page #60

Closed seqizz closed 6 years ago

seqizz commented 6 years ago

Hi,

I really liked the idea, but I have an implementation problem.

Running the binary on my server now. But I am not sure how to embed this inside an https website. Adding provided lines are no-go, since the service itself binds on 0.0.0.0 (public IP) and this application certainly doesn't provide SSL. My browser was not OK with this.

Embedding under nginx via proxy_pass just pops up weird problems, client.js is reachable but other paths are not etc. Here it what I use under nginx, which almost worked (tried to manage everything under comment-engine uri):

        location ~ ^/comment-engine(?<path>.*) {
            proxy_pass              http://127.0.0.1:9898/$path;
        }

It'd be great if you can show a working example. Seems like you did it for demo :grin:

vkuznecovas commented 6 years ago

If your website is running on https, you'll need to configure https for the back end as well. I'm running mouthful demo on AWS, so I can give details on an implementation of that, but not sure if that's relevant to your case. Where are you hosting your backend? Can you find a way to point an https address to your nginx?

In any case, currently the demo website is running with this included client side:

<div id="mouthful-comments" data-url="https://api.dizzy.zone/mouthful-demo"></div>
<script src="https://api.dizzy.zone/mouthful-demo/client.js"></script>

While the backend has an nginx in front of it with the following:

location /mouthful-demo/ {
            proxy_pass http://172.17.0.1:1224/;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Proto $scheme;
        add_header Cache-Control 'no-cache' always;
}
seqizz commented 6 years ago

I guess it was about parameters I passed as proxy headers, maybe it was caching before. Now with your exact config, I was able to run it without problems. Time to remove disqus. Thanks for help! (You might want to add the example nginx config to the documentation) :)