
user  root;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;
    upstream local {
        server 127.0.0.1:8081;
    }

    upstream twikoo {
        server 127.0.0.1:8084;
    }
    upstream frp_http_proxy {
        server 127.0.0.1:8085;
    }

    upstream frp_https_proxy {
        server 127.0.0.1:8086;
    }

    upstream frp_board {
        server 127.0.0.1:8087;
    }

    upstream meilisearch {
        server 127.0.0.1:7700;
    }

    server {
        listen 443 ssl;
        server_name gitea.amass.fun;
        ssl_certificate /etc/letsencrypt/live/gitea.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/gitea.amass.fun/privkey.pem;
        location / {
            client_max_body_size 512M;
            proxy_pass http://frp_http_proxy;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            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;
        }
    }

    server {
        listen 443 ssl;
        server_name unraid.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;
        client_max_body_size 512m;  #上传文件最大支持512m           

        ssl_certificate /etc/letsencrypt/live/unraid.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/unraid.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
            # access_by_lua_file lua/authentication.lua;
        }
    }

    server {
        listen 443 ssl;
        server_name pve.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;
        client_max_body_size 512m;  #上传文件最大支持512m           

        ssl_certificate /etc/letsencrypt/live/pve.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/pve.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_ssl_server_name on;
            proxy_ssl_name $host;
            proxy_pass https://frp_https_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name iot.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;           

        ssl_certificate /etc/letsencrypt/live/iot.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/iot.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name cloud.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;
        client_max_body_size 512m;  #上传文件最大支持512m           

        ssl_certificate /etc/letsencrypt/live/cloud.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/cloud.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_ssl_server_name on;
            proxy_ssl_name $host;
            proxy_pass https://frp_https_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name office.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;
        client_max_body_size 512m;  #上传文件最大支持512m           

        ssl_certificate /etc/letsencrypt/live/office.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/office.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_ssl_server_name on;
            proxy_ssl_name $host;
            proxy_pass https://frp_https_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name code.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;           

        ssl_certificate /etc/letsencrypt/live/code.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/code.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name photos.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s; 
        client_max_body_size 100m;           

        ssl_certificate /etc/letsencrypt/live/photos.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/photos.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name money.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;           

        ssl_certificate /etc/letsencrypt/live/money.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/money.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name emoney.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;           

        ssl_certificate /etc/letsencrypt/live/emoney.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/emoney.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name jellyfin.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s; 
        client_max_body_size 100m;           

        ssl_certificate /etc/letsencrypt/live/jellyfin.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/jellyfin.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name reader.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;     
        client_max_body_size 100m;         

        ssl_certificate /etc/letsencrypt/live/reader.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/reader.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name music.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s; 
        client_max_body_size 100m;           

        ssl_certificate /etc/letsencrypt/live/music.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/music.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name home.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;           

        ssl_certificate /etc/letsencrypt/live/home.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/home.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法
        
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 443 ssl;
        server_name notes.amass.fun;

        client_header_timeout 120s;         
        client_body_timeout 120s;           

        ssl_certificate /etc/letsencrypt/live/notes.amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/notes.amass.fun/privkey.pem;
        ssl_session_timeout 5m; #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
        ssl_prefer_server_ciphers on; #使用服务器端的首选算法

        underscores_in_headers on;
        # proxy_pass_request_headers on;

        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection $http_connection;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header x-wiz-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-Forwarded-Proto $scheme;
            proxy_pass http://frp_http_proxy;
        }
    }

    server {
        listen 80;
        server_name notes.amass.fun;
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl;
        http2 on;
        server_name amass.fun;
        ssl_certificate /etc/letsencrypt/live/amass.fun/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/amass.fun/privkey.pem;
        include server.conf;
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

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

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

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
