nginx——https

SERVER_IP=你的服务器IP

sudo mkdir -p /etc/nginx/ssl

sudo openssl req -x509 -nodes -newkey rsa:2048 \

-keyout /etc/nginx/ssl/openclaw.key \

-out /etc/nginx/ssl/openclaw.crt \

-days 365 \

-subj "/CN=${SERVER_IP}" \

-addext "subjectAltName = IP:${SERVER_IP}"

sudo dnf install -y nginx

sudo tee /etc/nginx/conf.d/openclaw.conf > /dev/null <<'EOF'

server {

listen 443 ssl http2;

server_name _;

ssl_certificate /etc/nginx/ssl/openclaw.crt;

ssl_certificate_key /etc/nginx/ssl/openclaw.key;

ssl_protocols TLSv1.2 TLSv1.3;

add_header Strict-Transport-Security "max-age=31536000" always;

location / {

proxy_pass http://127.0.0.1:18789;

proxy_http_version 1.1;

proxy_set_header Host $host;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_set_header X-Forwarded-For $remote_addr;

proxy_set_header X-Real-IP $remote_addr;

proxy_read_timeout 3600;

proxy_send_timeout 3600;

}

}

server {

listen 80;

server_name _;

return 301 https://hostrequest_uri;

}

EOF

sudo nginx -t

sudo systemctl enable --now nginx

sudo systemctl restart nginx

相关推荐
日取其半万世不竭7 分钟前
iftop、nethogs 和 nload:Linux 服务器网络流量实时监控工具介绍
linux·运维·服务器
mounter62519 分钟前
Linux 内核资源管理:控制组(cgroup)的演进与“策略组”新提案
linux·运维·服务器·cgroup·kernel
bksczm21 分钟前
文件在磁盘中的存储方式
linux·运维·服务器
Wpa.wk39 分钟前
win环境本地文件上传远程服务器(scp/远程连接工具)
运维·服务器
Dxy12393102161 小时前
为什么开了 `open_file_cache` 图片会不显示?
nginx
Soari1 小时前
SSH 主机密钥冲突
运维·网络·ssh
黑泽明Coding2 小时前
使用密钥登录ssh
运维·ssh
着迷不白2 小时前
五、文本处理工具+正则表达式
linux·运维·服务器
Elastic 中国社区官方博客2 小时前
每次操作一个 API 调用:Elastic Cloud Hosted 如何让大规模部署管理变得可行
大数据·运维·数据库·elasticsearch·搜索引擎·serverless
念何架构之路3 小时前
接入LVS+Nginx和服务发现
nginx·服务发现·lvs