0
点赞
收藏
分享

微信扫一扫

学Python可少不了项目练手,这8个小项目有趣又实用,小白也能做出来_python练手项目,python教程

追风骚年 2024-08-03 阅读 28

文章目录

背景:

  1. 应用程序已经通过U盘传入到服务器中。可以参考通过U盘传数据到 kylin系统
  2. 应用由多独立的服务组合而成, 且都是以docker容器来提供服务。
  3. docker image有: nginx, 后端extract个镜像
  4. 两个容器:mynginx, extract都可以独立运行起来了,可独立验证通过。

部署目标:

让整个应用都跑起来。

坑点:

  1. 在配置 nginx.conf文件时, 配置代理使用了extract容器的名称和IP地址,都不行。

验证过程及解决方案如下:

将以上情形转移到windows10系统下, 验证结果如下

  • nginx.conf file
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    types_hash_max_size 4096;
    client_max_body_size 1024m;

    keepalive_timeout  300;
    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
	    try_files $uri $uri/ /index.html;
        }

   	# location /api/ {
    #     	proxy_pass http://extract:9999/;
    # 	}
    
    location /xpi/ {
            # 1. 宿主机IP地址 不行
            proxy_pass http://127.0.0.1:7115/;

            # 2. 不行
            # proxy_pass http://0.0.0.0:7115/;  
            
            # 3. extract容器的IP地址 不行
            # proxy_pass http://172.19.0.3:7115/;#   
            
            # 4. extract容器名称,也是服务名称 不行
            # proxy_pass http://extract:7115/; 
            
            # 5. extract容器名称,也是服务名称 不行
            # proxy_pass http://extract/;
            
            # 6.windown10的以太网适配器 vEthernet (Default Switch)IP地址  OK
            # proxy_pass http://172.20.0.1:7115/;

            # 7. 以太网适配器 vEthernet (WSL): IP地址  OK
            # proxy_pass http://172.23.64.1:7115/;

            # 8. 未知适配器 Mihomo: OK
            # proxy_pass http://198.18.0.1:7115/;

            # 9. windows及macos下,使用特殊的host OK
            # proxy_pass http://host.docker.internal:7115/;
 
            # 10. linux下 使用docker0的IP地址 在其它linux服务器上验证 OK  (推荐到kylin服务器试一下)

            # 11. 使用host网络步骤:
            1. 将mynginx的docker-compose.yml文件中添加 `network_mode: host`
            2. 分别重试启用1,3,4
            3. 重启mynginx容器。
            4. 在nginx日志中及网页上验证不通过

        }
    
        
       
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}



举报

相关推荐

0 条评论