Skip to content

s3反代后无法使用 #1194

@Emtier

Description

@Emtier

配置反代后无法连接 image
http```

user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

stream {
log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';

access_log /www/wwwlogs/tcp-access.log tcp_format;
error_log /www/wwwlogs/tcp-error.log;
include /www/server/panel/vhost/nginx/tcp/*.conf;

}

events
{
use epoll;
worker_connections 51200;
multi_accept on;
}

http
{
include mime.types;
#include luawaf.conf;

	include proxy.conf;

lua_package_path "/www/server/nginx/lib/lua/?.lua;;";

    default_type  application/octet-stream;

    server_names_hash_bucket_size 512;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 50m;

    sendfile   on;
    tcp_nopush on;

    keepalive_timeout 60;

    tcp_nodelay on;

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 256k;
	fastcgi_intercept_errors on;

    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/json image/jpeg image/gif image/png font/ttf font/otf image/svg+xml application/xml+rss text/x-js;
    gzip_vary on;
    gzip_proxied   expired no-cache no-store private auth;
    gzip_disable   "MSIE [1-6]\.";

    limit_conn_zone $binary_remote_addr zone=perip:10m;
	limit_conn_zone $server_name zone=perserver:10m;

    server_tokens off;
    access_log off;
    log_format proxydebug '$time_local $remote_addr $request $status '
                 'host:$host upstream:$upstream_addr '
                 'headers_in:$http_authorization $http_x_amz_date $http_host';

include /www/server/panel/vhost/nginx/.conf;
include /www/wwwroot/GitHub/conf/nginx/
.conf;
}

server

server
{
server_name s3.test.com;
listen 80;
listen [::]:80;
listen 81;
listen [::]:81;
listen 443 ssl;
listen [::]:443 ssl;
listen 4430 ssl;
listen [::]:4430 ssl;
listen 443 quic;
listen [::]:443 quic;
listen 4430 quic;
listen [::]:4430 quic;
http2 on;
http3 on;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_tickets on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
add_header Alt-Svc 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443";quic=":4430"; h3=":4430"; h3-29=":4430"; h3-27=":4430";h3-25=":4430"; h3-T050=":4430"; h3-Q050=":4430";h3-Q049=":4430";h3-Q048=":4430"; h3-Q046=":4430"; h3-Q043=":4430"';

error_page 497 https://$host$request_uri;

if ($server_port !~ 443){
    rewrite ^(/.*)$ https://$host$1 permanent;
}
    ssl_certificate    /www/wwwroot/GitHub/cert/s3.test.com.pem;
ssl_certificate_key    /www/wwwroot/GitHub/cert/s3.test.com.key;

location / {
    proxy_pass http://127.0.0.1:1443;
    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;
    proxy_pass_request_headers on;
}

access_log /www/wwwroot/GitHub/logs/s3-proxy-debug.log proxydebug;
error_log  /www/wwwroot/GitHub/logs/s3.test.com.log;

}

debug

31/Aug/2025:19:03:40 +0800 240e:3c:2c10:4dc8 GET / HTTP/1.1 403 host:s3.test.com upstream:127.0.0.1:1443 headers_in:AWS4-HMAC-SHA256 Credential=PRqqzf6Xv6dKh/E0uuCE/20250831/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=e457e0b94c12ef2fda04b39e6a6cac59ce16c53cd5949558761a35e2c3371a57 20250831T110342Z s3.test.com:4430

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions