最近想自建短链,看到了 stilleshan 的项目,作者提供了完整的指南和配置文件,想着搭一个玩玩。根据作者的 docker-compose 文件,nginx 配置文件搭建好之后,尝试转换 subweb 的订阅链接,能转换成功返回短链,数据库也成功存储长链接数据,但通过短链访问长链确报 502 的错误,转换 Google ,bing 上别的网站的长链接能够正常跳转,甚至是作者自己搭建的短链也成功跳转(我的短链-->作者的短链-->长链),这让我非常困惑。
域名在 cloudflare 上托管着,用的 nginx 做反向代理
正常,可以接收短链的请求,有访问日志
ip.ip.ip.ip - - [30/Nov/2022:15:58:16 +0000] "GET /gpx3R8g HTTP/2.0" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.56" "ip.ip.ip.ip"
配置文件如下
server {
listen 80;
server_name a.b.c;
return 301 https://a.b.c$request_uri;
}
server {
listen 443 ssl http2;
server_name a.b.c;
index index.php index.html index.htm default.php default.htm default.html;
ssl_certificate /etc/nginx/ssl/a.b.c/fullchain1.pem;
ssl_certificate_key /etc/nginx/ssl/a.b.c/privkey1.pem;
gzip on;
ssl_stapling on;
ssl_stapling_verify on;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;
ssl_ecdh_curve secp384r1;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_session_tickets off;
resolver 8.8.8.8 8.8.4.4 valid=60s ipv6=off;
resolver_timeout 5s;
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
proxy_redirect off;
# proxy_http_version 1.1;
proxy_pass http://a.b.c:8002;
add_header 'Access-Control-Allow-Origin' '*';
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
client_max_body_size 100m;
client_body_buffer_size 128k;
}
# Pass PHP files to FPM.
# location ~ \.php$ {
# try_files $uri =404;
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
# }
# Deny hidden files.
location ~ /\. {
deny all;
}
# Forbidden files or directories
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) {
return 404;
}
# Directory verification related settings for one-click application for SSL certificate
location ~ \.well-known {
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
error_log /dev/null;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
access_log /var/log/nginx/a.b.c.access.log main;
error_log /var/log/nginx/a.b.c.error.log warn;
}
正常,可以存储长链和短链
正常,可以正确解析长链,返回短链
目前将问题定位在 cloudflare 上,但 cloudflare 免费版能设置的也就零星几个选项,想知道该怎么设置才能解除报 502 ,正常跳转到长链接
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.