目录

nginx代理gitee

背景

若干台agv设备,这些设备都是没有公网的(无法访问百度等)。

一台服务器(ubuntu20.04)有线可以公网,无线可以实现内部通信(agv,plc等设备)。

目的

agv每一次更新代码,拉取代码等都需要切换到有公网的网络,多台agv设备切来切去很麻烦。现在要实现agv通过服务器的nginx代理gitee拉取代码。

代理服务器配置步骤

更新源

bash 复制代码
sudo apt update

下载nginx

bash 复制代码
sudo apt install nginx

配置nginx

bash 复制代码
sudo nano /etc/nginx/site-available/gitee_proxy

配置文件内容

bash 复制代码
server {
    listen 80;   #端口这里自己定义,80被用了就用别的
    server_name 192.168.50.80;

    location / {
        proxy_pass https://gitee.com;
        proxy_set_header Host gitee.com;
        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;
    }
}

创建符号链接以启用新配置

bash 复制代码
sudo ln -s /etc/nginx/sites-available/gitee_proxy /etc/nginx/sites-enabled/

检查nginx配置是否正确

bash 复制代码
sudo nginx -t

重启nginx使配置生效

bash 复制代码
sudo systemctl restart nginx

AGV等其他需要代理到gitee的设备操作

bash 复制代码
git remote set-url origin http://192.168.50.80/username/repository.git
#这里的192.168.50.80就是ngixn配置server_name,ip为无网的服务器的ip
#这里的git请求由192.168.50.80服务器代理转发到gitee

检查设置是否成功

git remote -v 输出为++++http://192.168.50.80/用户名/仓库.git 则无问题++++

++++此时直接拉代码 就会提示输入用户名与密码 完成代码拉取++++

增加代理

拉取代码发现速度比较慢,网上查找后说要给gitee增加代理

git config --global https.proxy http://192.168.50.80:80

git config --global https.proxy https://192.168.50.80:80

克隆代码

git init

git clone http://192.168.50.80/repository.git

本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
GalaxyPokemon16 分钟前
MySQL基础 [一] - Ubuntu版本安装
linux·运维·ubuntu
柳鲲鹏28 分钟前
UBUNTU编译datalink
linux·运维·ubuntu
三阶码叟42 分钟前
centos7 yum install docker 安装错误
运维·docker·容器
CaliXz1 小时前
野草云防火墙风险分析及 Docker 使用注意事项
运维·docker·容器
计算机学无涯1 小时前
Docker 命令简写配置
运维·docker·容器
kk小源2 小时前
Docker常用操作教程
运维·docker·容器
Y淑滢潇潇3 小时前
RHCSA Linux 系统创建文件
linux·运维·服务器
奔跑的废柴3 小时前
Jenkins学习(B站教程)
运维·学习·jenkins
曹瑞曹瑞3 小时前
Linux制作deb安装包
linux·运维
YZF_Kevin3 小时前
centos安装dashboard详细步骤
linux·运维·centos