Ngnix farklı domainler ve websocket ayarları

server {
        server_name www.domain.com;
	root /var/www/domain.com/www;
	index index.html;
	listen 80;
	listen [::]:80;     
        location / {      
			try_files $uri $uri/ /index.html;
   }
}

server {
        server_name yonetim.domain.com;
	listen 80;
        location / {      
			proxy_pass         http://localhost:1452;
        		proxy_http_version 1.1;
        		proxy_set_header   Upgrade $http_upgrade;
       			proxy_set_header   Connection keep-alive;
        		proxy_set_header   Host $host;
        		proxy_cache_bypass $http_upgrade;
        		proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        		proxy_set_header   X-Forwarded-Proto $scheme;
   }
}  

server {
        server_name api.domain.com;
        location / {      
			proxy_pass http://localhost:1453;
   }
}  

server {
        server_name socket.domain.com;
        location / {
    
        access_log off;

        #  HTTP trafiği açto localhost:1454
        proxy_pass http://localhost:1454;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # WebSocket trafiğini ac(nginx 1.4)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
	}
} 
  

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir