    lua_package_path "/var/www/blog/?.lua;/var/www/braga/?.lua;/var/www/appphotos/?.lua;/var/www/apihh/?.lua;;"; 
    lua_code_cache off; 
    
    worker_processes auto;        
worker_rlimit_nofile 16000;
error_log /home/zoviet/lock/logs/nginx_error.log debug;


events {
    worker_connections 1000;
}

# Работа с замками через TCP сокеты

stream {
	lua_package_path "./home/zoviet/lock/?.lua;;";  
    lua_code_cache off; 
  
	init_by_lua '
		json = require "cjson";
		redis = require "resty.redis"            	
	';
	
    server {
        listen 4999;     
        set $redis_host "127.0.0.1";
		set $redis_port "6379";		
		error_log /home/zoviet/lock/logs/sockets.log debug;
        content_by_lua_file /home/zoviet/lock/tcp.lua;
    }
            
    server {
        listen 21; 
        proxy_pass 213.108.200.242:21;
    }
}

# TCP сокет для обмена с замками
    
    server {
		listen 4333 ssl;
		server_name  hh24lock.ru;

		ssl_certificate      /etc/letsencrypt/live/hh24lock.ru/fullchain.pem;
		ssl_certificate_key  /etc/letsencrypt/live/hh24lock.ru/privkey.pem;

		ssl_session_cache    shared:SSL:1m;
		ssl_session_timeout  5m;

		ssl_ciphers  HIGH:!aNULL:!MD5;
		ssl_prefer_server_ciphers  on;

        set $redis_host "127.0.0.1";
		set $redis_port "6379";
		
		error_log /home/zoviet/lock/logs/socket.log;
				
		location / {
			default_type 'plain/text';	
			content_by_lua_file /home/zoviet/lock/socket.lua;
		} 		
	}
   
    server {
		listen 80;
		server_name braga;
		root /var/www/braga;
		error_log /var/www/braga/logs/error.log;	
		
		set $template_root /var/www/braga/templates;		        
    	
    	location /public {         
            access_log off;          
        }
    		
		location / {		 
          default_type text/html;
		  add_header 'Access-Control-Allow-Origin' '*' always;
          proxy_connect_timeout 140;
          proxy_read_timeout 120;
          proxy_send_timeout 120;
          content_by_lua_file  /var/www/braga/front/index.lua;   
        }   
        
        location /archive {		 
          default_type text/html;
		  add_header 'Access-Control-Allow-Origin' '*' always;
          proxy_connect_timeout 140;
          proxy_read_timeout 120;
          proxy_send_timeout 120;
          content_by_lua_file  /var/www/braga/front/archive.lua;   
        }    
        
        location /room {		 
          default_type text/html;
		  add_header 'Access-Control-Allow-Origin' '*' always;
          proxy_connect_timeout 140;
          proxy_read_timeout 120;
          proxy_send_timeout 120;
          content_by_lua_file  /var/www/braga/front/room.lua;   
        }  

        location /logout {		 
          default_type text/html;
		  add_header 'Access-Control-Allow-Origin' '*' always;
          proxy_connect_timeout 140;
          proxy_read_timeout 120;
          proxy_send_timeout 120;
          try_files /templates/logout.html / =404;
        } 
        
        location /cellar {		 
          default_type text/html;
		  add_header 'Access-Control-Allow-Origin' '*' always;
          proxy_connect_timeout 140;
          proxy_read_timeout 120;
          proxy_send_timeout 120;
          content_by_lua_file  /var/www/braga/front/cellar.lua;   
        }     
    
        
        location ~* \.(?:css(\.map)?|js(\.map)?|yaml|ico|json|pdf|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$  {	          
            access_log off;
        }
        
	}
