Skip to content

Instantly share code, notes, and snippets.

@v0d1ch
Last active October 9, 2020 07:46
Show Gist options
  • Save v0d1ch/0bf71bc167efdac4856073d10f4c8859 to your computer and use it in GitHub Desktop.
Save v0d1ch/0bf71bc167efdac4856073d10f4c8859 to your computer and use it in GitHub Desktop.
nginx yesod setup as reverse proxy
upstream yesod {
server 127.0.0.1:3000;
keepalive 8;
}
# the nginx server instance
server {
listen 0.0.0.0:80;
server_name haskell-serbia.com;
access_log /var/log/nginx/access_yesod.log;
error_log /var/log/nginx/error_yesod.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://yesod/;
proxy_redirect off;
}
location /excluded {
return 403;
}
}
@benjamingoldstein
Copy link

To get the IP headers forwarded by nginx, to be logged by Yesod in production, I needed to do export YESOD_IP_FROM_HEADER=true. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment