espial icon indicating copy to clipboard operation
espial copied to clipboard

A sample nginx configuration

Open erdihu opened this issue 6 years ago • 2 comments

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.

erdihu avatar Oct 27 '19 15:10 erdihu

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

jonschoning avatar Oct 29 '19 20:10 jonschoning

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 :-)

matthewblott avatar Apr 15 '22 22:04 matthewblott