JCDani
JCDani

Reputation: 321

Nginx reverse proxy fails to redirect throwing 404 error

In my windows machine using wsl I have two docker containers minio and nginx. The container names are minio and nginx-proxy. The minio can be accessed using http://127.0.0.1:9001/login and http://localhost:9001/login. On adding 127.0.0.1 minio in C:\Windows\System32\drivers\etc\hosts, the url can be access as http://minio:9001/login.

The docker containers are created using the following commands

docker run -d -p 9000:9000 -p 9001:9001 --name minio --network minio-net -v /mnt/c/minio/data:/data -e "MINIO_ROOT_USER=minioadmin" -e "MINIO_ROOT_PASSWORD=minioadmin"   quay.io/minio/minio server /data --console-address ":9001"

docker run -d --name nginx-proxy --network minio-net -p 443:443 -p 80:80 nginx

I have modified the nginx/conf.d/default.conf to

server {
    listen       80;
    listen  [::]:80;
    server_name  minio;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    location /login {
        proxy_pass http://minio:9001/login;
    }
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

reloaded the nginx container

docker exec nginx-proxy nginx -t docker exec nginx-proxy nginx -s reload 

The logs look like below from nginx

2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 49
2025/02/22 18:51:51 [notice] 1#1: worker process 49 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 52
2025/02/22 18:51:51 [notice] 1#1: worker process 52 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 51
2025/02/22 18:51:51 [notice] 1#1: worker process 50 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: worker process 51 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 55
2025/02/22 18:51:51 [notice] 1#1: worker process 55 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 53
2025/02/22 18:51:51 [notice] 1#1: worker process 53 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 56
2025/02/22 18:51:51 [notice] 1#1: worker process 56 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received
2025/02/22 18:51:51 [notice] 1#1: signal 17 (SIGCHLD) received from 54
2025/02/22 18:51:51 [notice] 1#1: worker process 54 exited with code 0
2025/02/22 18:51:51 [notice] 1#1: signal 29 (SIGIO) received

what should I do to view the url in http://minio/login as currently it throws 404 error

Upvotes: -2

Views: 56

Answers (0)

Related Questions