user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    server_tokens off;

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

    server {
        listen 80;
	listen [::]:80;
	valid_referers none blocked server_names; # 限制 Referer 防盗链
        if ($invalid_referer) {
            return 403;
        }
        server_name www.catherinetan.cn;
        rewrite ^/(.*) https://www.catherinetan.cn$1 permanent; #填写自己域名
    }

    server #关键代码
    { 
    # SSL configuration
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;
    valid_referers none blocked server_names; # 限制 Referer 防盗链
    if ($invalid_referer) {
        return 403;
    }
    ssl_certificate /root/.acme.sh/www.catherinetan.cn_ecc/www.catherinetan.cn.crt; #你的ssl证书*.crt 或者 *.pem都可以
    ssl_certificate_key /root/.acme.sh/www.catherinetan.cn_ecc/www.catherinetan.cn.key; #你的ssl key
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;  #套件RSA和ecc不一样在下面我会分别给出
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    root /usr/share/nginx/html; #网页路径，这里也可以放你们自己的html网站替换下就可以了
    server_name www.catherinetan.cn; #你的服务器域名
 
    location /de451281-3375-4a07-8f93-39f5b247fd51 { 
        #切记路径需和v2ray服务器端和客户端保持一致,客户端ws后面路径需和此一致ws://@/de451281-3375-4a07-8f93-39f5b247fd51
        proxy_redirect off;
        proxy_pass http://127.0.0.1:8888; #此IP地址和端口需要和v2ray服务器端配置保持一致，
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
    }
    location /download {
	alias /data;
	autoindex on;
        autoindex_localtime on;
    }
    location /cn-download {
	rewrite ^/(.*) http://cn.catherinetan.cn:18880 permanent; #填写自己域名
    }
  }
}
