栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

使用nginx代理更新ubuntu的apt和elasticsearch

使用nginx代理更新ubuntu的apt和elasticsearch

名称定义

ProxyServer: 能上外网的服务器有2个IP,其中内网IP是192.168.0.10

Client: 不能上外网,希望通过ProxyServer进行更新的客户机,可以与ProxyServer连通。

配置ProxyServer

    安装nginx(不在这里介绍)

    增加一个nginx的子配置文件proxy_conf/proxys.conf:

cd /usr/local/nginx/conf
sudo mkdir proxy_conf && cd proxy_conf
touch proxys.conf
    用你喜欢的编辑器编辑proxys.conf
server {
    server_name localhost;
    
    # ubuntu的代理
    listen 9981;
       location / {
            proxy_pass http://mirrors.aliyun.com/ ;
        }
    # elasticsearch的代理
    listen 9982;    
       location / {
            proxy_pass https://artifacts.elastic.co/ ;
        }
 }
    将proxys.conf的内容增加到nginx的配置中,打开/usr/local/nginx/conf/nginx.conf
...
http
    {
    ...
    server
        {
        ...
        }
    # 在此处增加刚才编辑的proxy配置
    include proxy_conf/*.conf;
    }
    重启nginx,代理服务器设置完成。
配置Client 1. 配置ubunt apt的代理

(1) 打开/etc/apt/sources.list(注意备份)。

(2) 查找文本内容http://archive.ubuntu.com,替换为 http://192.168.0.10:9981

2. 配置elasticsearch的代理

(1) 打开/etc/apt/sources.list.d/elastic-7.x.list(注意备份)。

(2) 查找文本内容http://artifacts.elastic.co,替换为 http://192.168.0.10:9982

(3) 执行下面的命令添加elasticsearch的KEY

​ (参考[Install Elasticsearch with Debian Package | Elasticsearch Guide 8.0] | Elastic)

wget -qO - http://192.168.0.10:9982/GPG-KEY-elasticsearch | sudo apt-key add -
4. 更新
sudo apt update

参考链接:

看完这篇还不了解Nginx服务器配置,那我要哭了 - 简书 (jianshu.com)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/742818.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号