haiwen / seafile-docker

A Docker image for Seafile server
Other
544 stars 183 forks source link

Set the correct nginx config #227

Closed liamdemafelix closed 4 years ago

liamdemafelix commented 4 years ago

The default nginx config works great if the docker container is used as-is, but for some set ups where docker apps need to be proxied (like to nginx in the case of multiple virtual hosts per server), you should add the following config to the container's nginx configuration (/etc/nginx/sites-enabled/seafile.nginx.conf):

set_real_ip_from 172.17.0.0/24;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

This fixes issue #83, which was closed with a non-working resolution, since nginx inside the container will never see the real IP no matter what you put in the host's config, since it's not set to look for the correct headers.

The problem is this gets removed every time the docker container is restarted (for upgrades, etc.). There should be a way to make this persistent either by making the nginx config file shared (linked to /opt/seafile-data/ in the host) or have these hardcoded in the container directly.