Connecting Though a Reverse Proxy to ossn server.

Donald Wood Posted in Technical Support 5 years ago

I'm still looking for help with getting ossn working behind a nginx reverse proxy. I have one ip with many servers behind the reverse proxy. I can get the ssl certs to load on the reverse proxy machine for the ossn site. But the site shows no css and you can't login. Sense all traffic goes through the reverse proxy I can't put the ssl cert on the ossn server. Has anyone had simular setups? If so any ideas or suggestions? I have tried to modify the ossn.config file and used the https:example.com but I still could not get the traffic to go through. I have this on a home network so I don't have a cpanel just cli.

Replies
German Oliver F. Replied 4 years ago

Just want to share my solution.

My setup:
I use the Nginx Proxy Manager (NPM) as reverse proxy. NPM has a Let's Encrypt certificate for my Domain. It proxies the traffic to "http://[webserver's-IP]:80".

Problem:
Mixed Content, when accessing OSSN via https since the actual webserver has no SSL. When I change my URL in ossn.config.site.php to "https://[my-domain]" there are infinite redirects. Arsalan Shah's Code (see first answer) did not work for me.

Solution:
I generated a self signed certificate on the webserver (not (!) Let's Encrypt). The domain for this certificate is the webserver's IP. In NPM I changed the proxy target to "https://[webserver's-IP]:433". In ossn.config.site.php I set the URL to "https://[my-domain]". Now it works.

us Marc Peterson Replied 5 years ago

I just wanted to say the above code worked for my Nginx reverse proxy. Thanks!

gb Rishi B Replied 5 years ago

it's common for a reverse proxy that sets the HTTPXFORWARDED_PROTO header. a solution to this that may work without modifying ossn code would be to configure nginx to rewrite that header, as one of my earlier replies stated. https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/

us Donald Wood Replied 5 years ago

Arsalan Shah I swapped out your code and everything is up and running on https: . Is this a common problem? Just wondering thanks for the help.

~Z~ Man I did install and run the systeminfo and phpinfo the only thing that showed up was a lot of files were 755 and it said that it should be 644 and there were a lot of them. Thanks for that link.

German Michael Zülsdorff Replied 5 years ago

Instead of still guessing into the blue: please answer Arsalan's question, Donald.

There's a good chance we'll get the information by running the phpinfo subfunction of the System Info utility, so please follow the instructions in
https://www.opensource-socialnetwork.org/wiki/view/1101/how-to-report-a-bug-error
case A

gb Rishi B Replied 5 years ago

that sounds like it may be an issue of mixed content. if you're serving a site over https, your stylesheets have to also be loaded with https, not http. open up your developer's console and see if you see something that says "NET:ERR blocked by client" or something along those lines. This is an example of how that particular problem would look: https://stackoverflow.com/questions/15452519/problems-loading-style-sheets-over-https

us Donald Wood Replied 5 years ago

Bansh33 - It works just fine on http:// . When I install the cert it goes to the site but the site has no css and I can't login or navigate the site. I have also disabled cache and then changed the config file. then turned cache back on. It still showed the site without css. But I can get to the site with https: I have to revert back to http for the site to work.

gb Rishi B Replied 5 years ago

actually, you might not need to rewrite that header. I would first make sure your ssl cert is configured properly by following this guide: https://www.digitalocean.com/community/questions/self-hosted-ngrok-or-serveo-alternative

once you've verified that your ssl cert is working with your reverse proxy, try just following the instructions at https://www.opensource-socialnetwork.org/wiki/view/2671/how-to-enable-httpsssl-on-ossn

gb Rishi B Replied 5 years ago
gb Rishi B Replied 5 years ago

have you tried to see if you can get it working as over regular http? It sounds to me like an issue with the headers. You might need to rewrite the host header, this is how it's done with ngrok: https://ngrok.com/docs#http-host-header - i'm sure there's a similar option in nginx.