jonschoning / espial

Espial is an open-source, web-based bookmarking server.
GNU Affero General Public License v3.0
770 stars 26 forks source link

A sample nginx configuration #6

Open erdihu opened 4 years ago

erdihu commented 4 years ago

I know this is not a real issue but it might be good to include the necessary configurations to setup a reverse proxy. The following code snippet can be great help to others since the application requires some headers to be set and most browsers give mixed content error if the headers are not in place.

  location ^~ / {
  proxy_pass http://yourdomain.com:3000/;
  proxy_buffering off;
  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;
  }

Shortly, at least the following headers should be set:

The other's are not required to make CSS and JS files load correctly, however can be useful for other purposes.

One possible solution to remove the protocol dependency is to call the styles and scripts by omitting the protocol and letting the browser handling it: //domain.com/stlye.css I tried to find where this is being set but couldn't navigate myself safely in Haskell code.

jonschoning commented 4 years ago

I don't want to include a full proxy profile because different users have different needs, but i think your point about including some notes about X-Forwarded-Proto is a good one, i can add that to the readme

matthewblott commented 2 years ago

I know this is not a real issue but it might be good to include the necessary configurations to setup a reverse proxy. The following code snippet can be great help to others since the application requires some headers to be set and most browsers give mixed content error if the headers are not in place.

  location ^~ / {
  proxy_pass http://yourdomain.com:3000/;
  proxy_buffering off;
  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;
  }

Shortly, at least the following headers should be set:

  • Host
  • X-Forwarded-Proto

The other's are not required to make CSS and JS files load correctly, however can be useful for other purposes.

One possible solution to remove the protocol dependency is to call the styles and scripts by omitting the protocol and letting the browser handling it: //domain.com/stlye.css I tried to find where this is being set but couldn't navigate myself safely in Haskell code.

Thanks, this helped me out a tonne :-)