- 安装一些必要软件
1apt install curl vim wget unzip apt-transport-https lsb-release ca-certificates -y - 安装Nginx
12345678910111213#导入Keywget -O /etc/apt/trusted.gpg.d/nginx-mainline.gpg https://packages.sury.org/nginx-mainline/apt.gpg#导入源cat >> /etc/apt/sources.list.d/nginx.list << EOFdeb https://packages.sury.org/nginx-mainline/ $(lsb_release -sc) mainEOF#安装Nginxapt update && apt install nginx-extras -y#启动Nginxsystemctl enable nginx - 配置反向代理
- 反代其它域名
12345678910111213141516171819202122232425262728293031323334353637383940414243#被反向代理网址为nyaa.si 你的网址为nyaa.ukcat >> /etc/nginx/sites-enabled/nyaa.uk.conf << EOFserver {listen 80;listen [::]:80;listen 443 ssl http2;listen [::]:443 ssl http2;#ECCssl_certificate /etc/nginx/ssl/nyaa.uk_ECC.crt;ssl_certificate_key /etc/nginx/ssl/nyaa.uk_ECC.key;#RSAssl_certificate /etc/nginx/ssl/nyaa.uk_RSA.crt;ssl_certificate_key /etc/nginx/ssl/nyaa.uk_RSA.key;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;ssl_prefer_server_ciphers on;ssl_session_timeout 1d;ssl_session_cache shared:SSL:50m;ssl_session_tickets off;ssl_buffer_size 1400;add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";ssl_stapling on;ssl_stapling_verify on;server_name nyaa.uk www.nyaa.uk;if ($ssl_protocol = "") { return 301 https://$host$request_uri; }if ($host != nyaa.uk) { return 301 $scheme://nyaa.uk$request_uri; }location / {sub_filter_types text/css text/xml application/xhtml+xml application/xml;sub_filter nyaa.si nyaa.uk;sub_filter_once off;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Referer https://nyaa.si;proxy_set_header Host nyaa.si;proxy_pass https://nyaa.si;proxy_set_header Accept-Encoding "";}}EOF#重启Nginxsystemctl restart nginx - 同域名反代
12345678910111213141516171819202122232425262728293031323334353637383940414243#同域名反代nano /etc/hosts #修改前端hosts文件添加一行1.1.1.1 nyaa.uk #1.1.1.1为源站IPcat >> /etc/nginx/sites-enabled/nyaa.uk.conf << EOFserver {listen 80;listen [::]:80;listen 443 ssl http2;listen [::]:443 ssl http2;#ECCssl_certificate /etc/nginx/ssl/nyaa.uk_ECC.crt;ssl_certificate_key /etc/nginx/ssl/nyaa.uk_ECC.key;#RSAssl_certificate /etc/nginx/ssl/nyaa.uk_RSA.crt;ssl_certificate_key /etc/nginx/ssl/nyaa.uk_RSA.key;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;ssl_prefer_server_ciphers on;ssl_session_timeout 1d;ssl_session_cache shared:SSL:50m;ssl_session_tickets off;ssl_buffer_size 1400;add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";ssl_stapling on;ssl_stapling_verify on;server_name nyaa.uk www.nyaa.uk;if ($ssl_protocol = "") { return 301 https://$host$request_uri; }if ($host != nyaa.uk) { return 301 $scheme://nyaa.uk$request_uri; }location / {proxy_pass https://nyaa.uk;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 REMOTE-HOST $remote_addr;}}EOF#重启Nginxsystemctl restart nginx
- 反代其它域名