Skip to content

Reverse proxy & Docker : localhost:8080 is used instead of right URL #7209

@DB-CL

Description

@DB-CL

Please confirm you have done the following before posting your bug report:

Describe the bug
I cannot get SnipeIT to work properly in a docker container behind NGINX configured as a reverse proxy for this container.

I can put whatever I want into APP_URL, APP_TRUSTED_PROXIES and clear the cache with
php artisan config:clear && php artisan config:cache

SnipeIT has always the same behavior : the url are wrong (always localhost:8080)

I've read all related issues (most of them are closed by the bot with no updates). One interesting is this one : https://github.com/snipe/snipe-it/issues/6852 but I'm not sure I'm concerned since I think my problem is more a problem of APP_URL instead of APP_TRUSTED_PROXIES

Here is my setup:

My host has a public IP (212.x.x.x) and my container also has an IP (10.254.1.3 )

I'm accessing snipe it like this :
https://mydomain/snipeit which point to my public IP (212.x.x.x)

Docker is configured to map localhost:8080 (host) to localhost:80 (container)

NGINX on the host is configured like this :

location /snipeit/ {
     proxy_pass http://localhost:8080/;
     proxy_http_version 1.1;
     proxy_set_header X-Forwarded-Proto $scheme;
 }

And the SSL is managed by NGINX on the host

In the APP_URL I think I should have
APP_URL=https://mydomain/snipeit
But I also tried the public IP, the container IP, almost every single possibility.

In the APP_TRUSTED_PROXIES I think I should have
APP_TRUSTED_PROXIES=212.x.x.x,10.254.1.3
But like APP_URL, I tried everything I could think of.

The result is snipe it always trying to get the assets from http://localhost:8080/js/... I never had another result than this one, no matter what I put in APP_URL or APP_TRUSTED_PROXIES, and no matter how hard I try to rebuild the container, clear the cache, etc.

To Reproduce
Get the latest doker image and try to make it works behind NGINX as a reverse proxy.

Expected behavior
The SnipeIT setup page should display properly, getting the assets from this URL : https://mydomain/snipeit/js/.... instead of http://localhost:8080/js/...

Server (please complete the following information):

  • Snipe-IT Version I think this is 4.7.5
  • OS: [e.g. Ubuntu, CentOS] host is debian 9
  • Web Server: [e.g. Apache, IIS] host is nginx
  • PHP Version : the one in docker

I don't know if I'm missing something or if there is some sort of a bug.

Thanks for your help

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions