本帖最后由 VaporTang 于 2023-6-24 23:13 编辑
前置:我的路由器wan口是有运营商的公网ip的 外网80和443自然也是被约束了的
在配置里开放端口访问权限后
目前外网用我的域名:8090是可以访问这个容器的 (http)

然后我的折腾开始了
我希望外网可以使用https连接到我的docker容器 [浏览器提示不安全非常不顺眼]
已经申请到了.pem证书了
开始研究nginx
尝试配置,但是对nginx一窍不通
我是让nginx把uci干掉了,然后似乎目前我路由器也没有uhttpd[不知道为啥,但是我openwrt web是正常的]
先贴一个默认的配置[这个配置一切正常,浏览器192.168.1.1就是openwrt的web ui]
- worker_processes auto;
- user root;
- events {}
- http {
- access_log off;
- log_format openwrt
- '$request_method $scheme://$host$request_uri => $status'
- ' (${body_bytes_sent}B in ${request_time}s) <- $http_referer';
- include mime.types;
- default_type application/octet-stream;
- sendfile on;
- client_max_body_size 2048M;
- client_body_buffer_size 8192M;
- large_client_header_buffers 2 1k;
- gzip on;
- gzip_vary on;
- gzip_proxied any;
- root /www;
- server { #see uci show 'nginx._lan'
- listen 80;
- listen [::]:80;
- server_name _lan;
- include restrict_locally;
- include conf.d/*.locations;
- access_log off; # logd openwrt;
- }
- include conf.d/*.conf;
- }
复制代码 然后我尝试修改成下面的就发现内网访问192.168.1.1(路由器内网ip)就会提示
嗯… 无法访问此页面192.168.1.1 已拒绝连接。 这个配置真的纯属乱写,大佬勿喷,我已经socat把外部8443转到内部443了,所以下面有个8443
- events {}
- http {
- access_log off;
- log_format openwrt
- '$request_method $scheme://$host$request_uri => $status'
- ' (${body_bytes_sent}B in ${request_time}s) <- $http_referer';
- include mime.types;
- default_type application/octet-stream;
- sendfile on;
- client_max_body_size 2048M;
- client_body_buffer_size 8192M;
- large_client_header_buffers 2 1k;
- gzip on;
- gzip_vary on;
- gzip_proxied any;
- root /www;
- server {
- listen 80;
- listen [::]:80;
- server_name _lan;
- include restrict_locally;
- include conf.d/*.locations;
- access_log off; # logd openwrt;
- }
- server {
- listen 8443 ssl;
- server_name domain; # 域名我就不贴了
- ssl_certificate /etc/nginx/conf.d/domain.cert.pem;
- ssl_certificate_key /etc/nginx/conf.d/domain.key.pem;
- location / {
- proxy_pass http://localhost:8090;
- 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_redirect off;
- }
- }
- include conf.d/*.conf;
- }
复制代码
希望能来个大佬帮我看看,只要能实现我目的就行,不是必须得用nginx
感觉我有点啰嗦,但是主要我是希望可以把我的网络环境全面的讲一下,openwrt各种冲突都爱好了?
核心目的就一个吧
外网在浏览器地址栏输入我的域名:8090,https连接到我的路由器然后可以访问到docker容器
万分感激
|