본문 바로가기
개발/ubuntu

[ubuntu] Nginx + Socket.io 설정

by 적아38 2021. 7. 1.
728x90

server {
    listen  80;
 
    server_name socket.com;
    server_tokens off;
 
    access_log  /var/log/nginx/socket.access.log  main;
    error_log  /var/log/nginx/socket.error.log;
 
    #소켓 전용.
    location / {
        proxy_pass http://localhost:2800/;
        chunked_transfer_encoding off;
        proxy_buffering   off;
        proxy_set_header Upgrade websocket;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;  # This line.
        proxy_set_header Host $host;
        proxy_http_version 1.1;
    }
 
    #socket.io.js파일 전용.
    location /socket.io/ {
        proxy_pass http://localhost:2800/socket.io/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
 
        proxy_buffers 8 32k;
        proxy_buffer_size 64k;
 
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
    }
 
}

728x90

'개발 > ubuntu' 카테고리의 다른 글

[ubuntu] SSL 갱신  (0) 2021.08.13
[ubuntu] nginx 경로  (0) 2021.07.01
[ubuntu] Argument list too long  (0) 2021.06.23
[ubuntu] mysql replication 설정  (0) 2021.06.11
[nginx] mysql conf 수정 및 재실행  (0) 2021.05.24

댓글