attu icon indicating copy to clipboard operation
attu copied to clipboard

reverse proxy by nginx error

Open v4if opened this issue 2 years ago • 16 comments

Describe the bug: behind nginx with a sub path, how to set the resource root path with the sub path such as: http://example.com/path/to/milvus

nginx config:

  location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006;
    proxy_set_header Host $http_host;
  }

request the url:http://example.com/path/to/milvus,response the error: image

Attu version: zilliz/attu:v2.2.8

v4if avatar Nov 10 '23 09:11 v4if

Try this?

location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006/;
    proxy_set_header Host $http_host;
  }

shanghaikid avatar Nov 21 '23 10:11 shanghaikid

Try this?

location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006/;
    proxy_set_header Host $http_host;
  }

Connect request url 404,request directly from the root path https://example.com/api/v1/milvus/connect without including subpath /path/to/milvus/, it should be https://example.com/path/to/milvus/api/v1/milvus/connect image

v4if avatar Nov 22 '23 05:11 v4if

Try this?

location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006/;
    proxy_set_header Host $http_host;
  }

Connect request url 404,request directly from the root path https://example.com/api/v1/milvus/connect without including subpath /path/to/milvus/, it should be https://example.com/path/to/milvus/api/v1/milvus/connect image

I'm not the expert of nginx. From the case, it looks like you should proxy https://example.com/path/to/milvus/api/* to http://11.132.42.228:30006/api/*; not sure how to write the rule, you can do some experiments.

shanghaikid avatar Nov 22 '23 06:11 shanghaikid

This url https://example.com/api/v1/milvus/connect seems to be returned by attu's backend, like$root_url/api/v1/milvus/connect, Is there any way to modify the root_url to https://example.com/path/to/milvus of attu?

Just like run-grafana-behind-a-proxy: image

https://grafana.com/tutorials/run-grafana-behind-a-proxy/ @shanghaikid

v4if avatar Nov 22 '23 06:11 v4if

I see. will fix it soon.

shanghaikid avatar Nov 22 '23 06:11 shanghaikid

Did the problem fixed? Have met the same problem of the url /api/xxx

carlwang99 avatar Dec 04 '23 07:12 carlwang99

Did the problem fixed? Have met the same problem of the url /api/xxx

For the release v2.3.3, you can setup HOST_URL as the docker env, then you can set a correct root url.

shanghaikid avatar Dec 04 '23 07:12 shanghaikid

Did the problem fixed? Have met the same problem of the url /api/xxx

For the release v2.3.3, you can setup HOST_URL as the docker env, then you can set a correct root url.

o thank u is there an example of HOST_URL setting i am using nginx proxy, too

carlwang99 avatar Dec 04 '23 07:12 carlwang99

I don't have the env, but I can give you an example, you need to test it by yourself:)

location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006/;
    proxy_set_header Host $http_host;
  }

dock run -e HOST_URL= /path/to/milvus/  -p 30006:3000 zilliz/attu:v2.3.3

For this case, all the requests send from you browsers should be prefixed with /path/to/milvus/ . and it should go to the real address behind the /path/to/milvus/

shanghaikid avatar Dec 04 '23 07:12 shanghaikid

I don't have the env, but I can give you an example, you need to test it by yourself:)

location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006/;
    proxy_set_header Host $http_host;
  }
dock run -e HOST_URL= /path/to/milvus/  -p 30006:3000 zilliz/attu:v2.3.3

For this case, all the requests send from you browsers should be prefixed with /path/to/milvus/ . and it should go to the real address behind the /path/to/milvus/

ok, it works dock run -e HOST_URL= /path/to/milvus/ -p 30006:3000 zilliz/attu:v2.3.3 location /example/vec/ {
proxy_pass http://localhost:30006/;
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;
}

location /path/to/milvus/ {
proxy_pass http://localhost:30006/;
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;
}

carlwang99 avatar Dec 04 '23 07:12 carlwang99

I don't have the env, but I can give you an example, you need to test it by yourself:)

location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006/;
    proxy_set_header Host $http_host;
  }
dock run -e HOST_URL= /path/to/milvus/  -p 30006:3000 zilliz/attu:v2.3.3

For this case, all the requests send from you browsers should be prefixed with /path/to/milvus/ . and it should go to the real address behind the /path/to/milvus/

ok, it works dock run -e HOST_URL= /path/to/milvus/ -p 30006:3000 zilliz/attu:v2.3.3 location /example/vec/ { proxy_pass http://localhost:30006/; 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; }

location /path/to/milvus/ { proxy_pass http://localhost:30006/; 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; }

Thanks! I meet the same problem. Now I followed this configuration and I can login to see users, roles and metrics. But I cannot see the database! (see the figure below. There should be a database and a collection.) shot_20240410-174900

Milvus is deployed at host 10.15.85.78, attu is deployed at host 10.15.86.23, nginx is deployed at local. The docker-compose for attu is as follows:

version: '3.8'        
                      
services:             
  attu:               
    image: zilliz/attu:v2.3.9
    container_name: attu
    restart: always   
    hostname: attu       
    environment:         
      - MILVUS_URL=10.15.85.78:19530
      - HOST_URL=/attu                                                                                                                        
    ports:            
      - 5949:3000 

The configuration of nginx:

location /attu/ {
            proxy_set_header Host $http_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;
            proxy_pass http://10.15.86.23:5949/;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
} 

Any help would be greatly appreciated.

sky-cloud avatar Apr 10 '24 09:04 sky-cloud

I don't have the env, but I can give you an example, you need to test it by yourself:)

location /path/to/milvus/ {
    proxy_pass http://11.132.42.228:30006/;
    proxy_set_header Host $http_host;
  }
dock run -e HOST_URL= /path/to/milvus/  -p 30006:3000 zilliz/attu:v2.3.3

For this case, all the requests send from you browsers should be prefixed with /path/to/milvus/ . and it should go to the real address behind the /path/to/milvus/

ok, it works dock run -e HOST_URL= /path/to/milvus/ -p 30006:3000 zilliz/attu:v2.3.3 location /example/vec/ { proxy_pass http://localhost:30006/; 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; } location /path/to/milvus/ { proxy_pass http://localhost:30006/; 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; }

Thanks! I meet the same problem. Now I followed this configuration and I can login to see users, roles and metrics. But I cannot see the database! (see the figure below. There should be a database and a collection.) shot_20240410-174900

Milvus is deployed at host 10.15.85.78, attu is deployed at host 10.15.86.23, nginx is deployed at local. The docker-compose for attu is as follows:

version: '3.8'        
                      
services:             
  attu:               
    image: zilliz/attu:v2.3.9
    container_name: attu
    restart: always   
    hostname: attu       
    environment:         
      - MILVUS_URL=10.15.85.78:19530
      - HOST_URL=/attu                                                                                                                        
    ports:            
      - 5949:3000 

The configuration of nginx:

location /attu/ {
            proxy_set_header Host $http_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;
            proxy_pass http://10.15.86.23:5949/;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
} 

Any help would be greatly appreciated.

looks like the websocket is not forwarded. can you enable the big request rows on chrome inspector?

image

shanghaikid avatar Apr 10 '24 10:04 shanghaikid

looks like the websocket is not forwarded. can you enable the big request rows on chrome inspector?

image

Thank you. I enable the big request rows on chrome inspector. Please see the screenshots blew. shot_20240411-102832

And also the header info: shot_20240411-102857

sky-cloud avatar Apr 11 '24 02:04 sky-cloud

@sky-cloud can you check this, if this is empty, I think the HOST_URL is not set correctly. image

shanghaikid avatar Apr 11 '24 02:04 shanghaikid

@sky-cloud can you check this, if this is empty, I think the HOST_URL is not set correctly. image

@shanghaikid Thanks for you reply. The _env_.HOST_URL is as follows: shot_20240411-133036

sky-cloud avatar Apr 11 '24 05:04 sky-cloud

@shanghaikid Some additional notes may be helpful.

  1. Although I cannot see the database or collection, I can create new collection in default database. see the screenshots follow: shot_20240411-134448

I create a collection named new_col and see the notification of success: shot_20240411-134507

  1. If I use location / {...} other than location /somepath {...} in nginx, then everything is OK. Under this condition the env variable HOST_URL is also not necessary for running zilliz/attu. Now I can see the collection new_col in the default database: shot_20240411-134642

sky-cloud avatar Apr 11 '24 05:04 sky-cloud

server {
  listen 8080;
  server_name localhost;

  location /attu/ {
    proxy_pass http://localhost:3000/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    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;
    rewrite ^/attu/(.*)$ /$1 break;
  }
}

This conf works for me.

image

shanghaikid avatar May 30 '24 02:05 shanghaikid