
配置文件是
server { listen 443 ssl; ssl_certificate /etc/nginx/ssl/certificate.crt; ssl_certificate_key /etc/nginx/ssl/private.key; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location /minio/ { proxy_pass http://127.0.0.1:9090/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; } } 日志是
2022/03/08 01:49:20 [error] 24#24: *2 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET /minio/ HTTP/1.1", upstream: "https://127.0.0.1:9090/", host: "xxx.xxx.xxx.xxx" 访问 https://xxx.xxx.xxx.xxx/minio 显示 502 错误
我好像把配置文件搞乱了
现在这样配置也访问不了 https://ip ,之前是可以的
server { listen 443 ssl; ssl_certificate /etc/nginx/ssl/certificate.crt; ssl_certificate_key /etc/nginx/ssl/private.key; location / { root /usr/share/nginx/html/; index index.html; } } 1 dier 2022-03-08 10:15:34 +08:00 怎么看日志 upsteram 显示的是 https://127.0.0.1:9090 。配错了还是你粘错了。nginx 先不用 HTTPS 试试能不能正常访问 |
2 zxCoder OP @dier 哦哦 那个日志是我上一次改的复制的,现在已经改成代理到 http://127.0.0.1:9090/ ,但是还是不行 然后我用 ssh 代理直接在本地访问 http://127.0.0.1:9090 是可以的 |
3 jowan 2022-03-08 10:26:10 +08:00 |
4 dier span class="ago" title="2022-03-08 10:37:08 +08:00">2022-03-08 10:37:08 +08:00 @zxCoder 你先把 location 部分的 /minio/ 改成 / 试试吧,反代这个位置很容易出现问题 |
5 zxCoder OP @dier server { listen 443 ssl; ssl_certificate /etc/nginx/ssl/certificate.crt; ssl_certificate_key /etc/nginx/ssl/private.key; location / { proxy_pass https://127.0.0.1:9090; } } 这样子直接访问 https://ip 就 502 了,但是 http://ip 又出现了 nginx 那个 index.html 。。但是我已经把其他的配置都关了 |
6 Vegetable 2022-03-08 10:41:59 +08:00 最好别 http://host/minio/这么代理,而使用 minio.host.com 这种模式。 这是官方不支持的方式,好像也有人做到了,反正当初我发现比较麻烦,就放弃了。 |
7 Vegetable 2022-03-08 10:42:03 +08:00 |
8 anonydmer 2022-03-08 10:42:14 +08:00 按照 3 楼贴的官方文档来 |
10 anonydmer 2022-03-08 10:45:37 +08:00 再补充点吧,1. 推荐用单独的域名模式; 2. 不要自己用路径还要 rewrite ,没用,你这写了 S3 的签名计算结果能匹配么 |
11 gadfly3173 2022-03-08 10:47:15 +08:00 @zxCoder #5 因为你只配了 443 没有指定 default server ,也没有指定 80 的 default ,所以用 ip 访问当然什么也看不到 |
12 Vegetable 2022-03-08 10:47:34 +08:00 @zxCoder 只有 ip 就换端口。反正你这么代理,可能会导致签名 url 无法使用,默认的控制面板可能也会出问题。 |
13 gadfly3173 2022-03-08 10:48:27 +08:00 @zxCoder #9 话说买个域名也不贵吧 内网也可以解析的 |
14 lscexpress 2022-03-08 10:50:17 +08:00 如果你是本地环境那 127.0.0.1:9090 应该不会出错,如果你部署到公网,那你应该用 0.0.0.0:9090 |
15 dier 2022-03-08 10:52:04 +08:00 关掉 nginx 其它的 server 块配置,然后用下面的试试 ```config server { server_name YOUR_IP; listen 80; location / { 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_set_header Host $http_host; proxy_pass http://127.0.0.1:9090/; } } |
17 zxCoder OP 感觉得重装了,配置都搞乱了 |
18 dier 2022-03-08 11:20:53 +08:00 nginx 的配置文件没有很复杂,还原很简单的。你的 nginx 跟 minio 是在同一台机器上吗 |
19 zxCoder OP @dier 是的,都是 docker 容器,这个有关系吗 我现在 nginx 的配置是 my.conf: ``` server { listen 80; server_name ip.ip.ip.ip; return 301 https://ip.ip.ip.ip$request_uri; } server { listen 443 ssl; server_name ip.ip.ip.ip; ssl_certificate /etc/nginx/ssl/certificate.crt; ssl_certificate_key /etc/nginx/ssl/private.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; location / { root /usr/share/nginx/html/; index index.html; # proxy_set_header Host $http_host; # proxy_pass http://localhost:9090; } } ``` nginx.conf: ``` user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/my.conf; } ``` minio 没有其他的配置,就刚刚按官方文档加了 https ,现在 ssh 代理能访问 https://127.0.0.1:9090 |
20 jowan 2022-03-08 11:44:03 +08:00 你 nginx 如果也是 docker 的话 ip 不能填本机 ip |
21 dier 2022-03-08 11:44:57 +08:00 nginx 也是容器的话 proxy_pass 就不能用 127.0.0.1 这个地址,要用宿主机的实际网卡 IP |
24 yuchenr 2022-03-08 14:33:00 +08:00 现在控制台和业务不是同一个端口 |