Skip to content

webController에 라우팅을 제대로 했음에도 불구하고 구글 로그인 페이지가 반환되지 않던 문제  #30

Description

@zbezdac1f

Nginx 설정을 통해 Google 로그인 페이지와 같은 특정 경로를 처리하도록 하려면, 해당 경로에 대해 적절한 location 블록을 추가해야 했다.
나는 그점을 인지하지 못하였고 , 매우 오래 헤매였다. 결론은 nginx 에서 블록 처리를 해줬어야 했음.
수정전
worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;

    location / {
        try_files $uri /index.html;
    }

    location /sub {
        proxy_pass http://fastapi:8000/;
        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 /server {

    # allow 127.0.0.1;
    # deny all;
    
    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;

    proxy_pass http://springboot:8080;
}
}

}

수정 후
worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html; # 정적 파일이 있는 디렉토리
index index.html index.htm;

    # 정적 파일 처리
    location / {
        try_files $uri $uri/ /index.html; # 요청된 파일이 없을 경우 index.html로 리다이렉트
    }

    # Naver 로그인 페이지 처리
    location /naverLogin {
        alias /usr/share/nginx/html/naverLogin.html; # naverLogin.html 파일 경로
        add_header Content-Type text/html; # HTML 파일로 반환
    }

    # Google 로그인 페이지 처리
    location /googleLogin {
        alias /usr/share/nginx/html/googleLogin.html; # googleLogin.html 파일 경로
        add_header Content-Type text/html; # HTML 파일로 반환
    }

    # FastAPI 프록시 설정
    location /sub {
        proxy_pass http://fastapi:8000/;
        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;
    }

    # Spring Boot 프록시 설정
    location /server {
        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;
        proxy_pass http://springboot:8080;
    }
}

}

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions