admin管理员组文章数量:1122832
here is my nginx config file,
server {
listen 80;
server_name api.xxxx.io;
client_max_body_size 50M;
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/public.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
location / {
proxy_pass http://backend:4242;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set_real_ip_from 103.21.244.0/22;
real_ip_header CF-Connecting-IP;
}
location /socket.io/ {
proxy_pass http://backend:4242;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}
I can reach the api.xxxx.io with and see the logs. But when I try I can not reach my website and there is no logs. I am also redirecting via cloud flare. Can anyone help
here is my nginx config file,
server {
listen 80;
server_name api.xxxx.io;
client_max_body_size 50M;
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/public.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
location / {
proxy_pass http://backend:4242;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set_real_ip_from 103.21.244.0/22;
real_ip_header CF-Connecting-IP;
}
location /socket.io/ {
proxy_pass http://backend:4242;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}
I can reach the api.xxxx.io with http://api.xxxx.io and see the logs. But when I try https://api.xxxx.io I can not reach my website and there is no logs. I am also redirecting via cloud flare. Can anyone help
Share Improve this question asked Nov 21, 2024 at 14:01 Salih Burak ÇoşkunSalih Burak Çoşkun 911 gold badge1 silver badge5 bronze badges 2 |1 Answer
Reset to default 2I recommend trying a configuration like this. It’s important to properly separate ports 80 and 443 to ensure everything works correctly.
server {
if ($host = api.xxxx.io) {
return 301 https://$host$request_uri;
}
listen 80;
server_name api.xxxx.io;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name api.xxxx.io;
client_max_body_size 50M;
ssl_certificate /etc/nginx/ssl/public.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
location / {
proxy_pass http://backend:4242;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set_real_ip_from 103.21.244.0/22;
real_ip_header CF-Connecting-IP;
}
location /socket.io/ {
proxy_pass http://backend:4242;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}
本文标签: dockerNginx listens http but not httpsStack Overflow
版权声明:本文标题:docker - Nginx listens http but not https - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310196a1934289.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
server
block is ok, and splitting your server block in two most likely wouldn't solve the problem. This is looks like a firewall or CloudFlare setup issue. What is your CloudFlare SSL mode (Off/Flexible/Full/Full (strict))? – Ivan Shatsky Commented Nov 21, 2024 at 20:30