2P3S / 2p3s-scrum-dice

🃏 A real-time voting system built with Next.js 13 using the app directory and based on the Atomic Design Pattern
0 stars 0 forks source link

NGINX Reverse Proxy #126

Open hyunnnn98 opened 11 months ago

hyunnnn98 commented 11 months ago

변경 내용

이렇게 Nginx 설정 파일을 업데이트하려 합니다.

이슈 내용

현재 Nginx 설정 파일에는 Next.js 및 Nest.js 애플리케이션을 프록시하는 설정이 포함되어 있습니다. 이 설정은 80번 포트에서 웹 애플리케이션을 제공하고, WebSocket 연결도 관리합니다.

변경 내용

이 설정에서 주요 변경 사항은 다음과 같습니다:

  1. server_name을 실제 도메인 이름 또는 호스트 이름으로 변경하세요.
  2. location /api/scrum-dicelocation /socket.ioproxy_pass 주소를 애플리케이션의 실제 주소로 변경하세요.
  3. 필요한 경우 SSL 설정을 추가하여 보안을 강화하세요.

새로운 설정 파일:


# 새로운 Nginx 설정 파일

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile            on;
    tcp_nopush          on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    upstream websocket {
        server 127.0.0.1:8080;
    }

    server {
        listen 80;
        server_name your_domain.com;  # 도메인 이름 또는 호스트 이름으로 변경

        location / {
            proxy_pass http://127.0.0.1:3000; # Next.js 애플리케이션의 주소로 변경
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }

        location /api/scrum-dice {
            proxy_pass http://127.0.0.1:8080; # Nest.js HTTP 애플리케이션의 주소로 변경
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }

        location /socket.io {
            proxy_pass http://websocket;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
        }

        location /scrum-dice {
            proxy_pass http://websocket;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
        }
    }
}
hyunnnn98 commented 11 months ago

Todo: @Samsam-lee