网路代理环境设置

一、普通浏览器代理设置

 1.  新增编辑 /etc/profile.d/proxy.sh文件,内容如下:

http_proxy=192.168.8.XXX:8789
ftp_proxy=192.168.8.XXX:8790
https_proxy=192.168.8.XXX:8789
no_proxy=192.168.8.0/24,127.0.0.1,192.168.2.0/24,localhost


export http_proxy
export https_proxy
export ftp_proxy
export no_proxy

二、Docker代理设置

配置docker service

 mkdir -p /etc/systemd/system/docker.service.d

新建编辑文件/etc/systemd/system/docker.service.d/http-proxy.conf

[Service]

Environment="HTTP_PROXY=http://192.168.8.XXX:8789/"
Environment="HTTPS_PROXY=http://192.168.8.XXX:8789/"
Environment="NO_PROXY=home.eyun.online,192.168.8.100"

重启docker 

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

三、Docker私有服务器设置

1. docker proxy设置

2. docker host配置

3. docker group设置

4. docker 客户端设置

vi /etc/docker/daemon.json
{
  "insecure-registries" : ["http://192.168.8.XXX:8083", "http://192.168.8.XXX:8082"]
}
vi .m2/settings.xml
<settings>
    <servers>
        <server>
            <id>xxx-release</id>
            <username>your nexus user</username>
            <password>your nexus password</password>
        </server>
    </servers>
</settings>

 5. docker 客户端proxy设置

vi /etc/docker/daemon.json
{
  "insecure-registries" : ["http://192.168.8.XXX:8083", "http://192.168.8.XXX:8082"],
   "proxies": {
     "http-proxy": "http://192.168.8.XXX:PORT",
     "https-proxy": "http://192.168.8.XXX:PORT",
     "no-proxy": "*.example.com,.example.com,192.168.8.0/24,127.0.0.0/8"
   }
}
vi  ~/.docker/config.json
{
         "proxies": {
           "default": {
             "httpProxy": "http://192.168.8.XXX:PORT",
             "httpsProxy": "http://192.168.8.XXX:PORT",
             "noProxy": "*.example.com,.example.com,127.0.0.0/8"
           }
         },
        "auths": {
                "home.example.com:8082": {
                        "auth": "ZGVwbG95bWVudDXBsb3lleXVu"
                },
                "home.example.com:8083": {
                        "auth": "ZGVwbG95bWVupkZXBsb3lleXVu"
                }
        }
}

4. maven工程设置 

设置jib-maven-plugin.image

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.eyun</groupId>
    <artifactId>welkin-monolith</artifactId>
    <version>0.0.1-${git.branch}-${git.build.time}.${git.commit.id.abbrev}</version>
    <packaging>jar</packaging>
    <name>Welkin Monolith</name>
    <description>Description for WelkinMonolith</description>

    <repositories>
        <repository>
            <id>central</id>
            <name>central repository</name>
            <url>https://your maven url:8081/repository/maven-public/</url>
            <releases>
               <enabled>true</enabled>
            </releases>
            <snapshots>
              <enabled>false</enabled>
            </snapshots>
        </repository>
        <!-- jhipster-needle-maven-repository -->
    </repositories>

    <pluginRepositories>
        <!-- jhipster-needle-maven-plugin-repository -->
    </pluginRepositories>

    <!-- jhipster-needle-distribution-management -->

    <properties>
        <!-- Build properties -->
        <maven.version>3.2.5</maven.version>
        <java.version>1.8</java.version>
        <node.version>v16.17.0</node.version>
        <npm.version>8.19.1</npm.version>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        。。。。。。

        <jib-maven-plugin.version>3.2.1</jib-maven-plugin.version>
        <jib-maven-plugin.image>https://your nexus url:8083/eclipse-temurin:8-jdk</jib-maven-plugin.image>
        。。。。。。

        <!-- jhipster-needle-maven-property -->
    </properties>
    。。。。。。
</project>

四、node代理设置

参考:https://github.com/eirslett/frontend-maven-plugin

(一)node和npm包的proxy下载设置

1、通过maven设置的proxy方式(验证过)

vi ~/.m2/settings.xml

编辑内容如下

<settings>
    <servers>
        <server>
            <id>xxx-release</id>
            <username>your nexus user</username>
            <password>your nexus password</password>
        </server>
    </servers>
    <proxies>
        <proxy>
            <active>true</active>
            <protocol>http</protocol>
            <host>192.168.8.xxx</host>
            <port>8789</port>
            <nonProxyHosts>192.168.8.0/24</nonProxyHosts>
        </proxy>
        <proxy>
            <active>true</active>
            <protocol>https</protocol>
            <host>192.168.8.xxx</host>
            <port>8789</port>
            <nonProxyHosts>192.168.8.0/24</nonProxyHosts>
        </proxy>
    </proxies>
</settings>

2、通过maven工程的pom.xml中的downloadRoot设置(未验证)

<plugin>
    ...
    <executions>
        <execution>
            <!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
            <!-- optional: default phase is "generate-resources" -->
            <phase>generate-resources</phase>
        </execution>
    </executions>
    <configuration>
        <nodeVersion>v4.6.0</nodeVersion>

        <!-- optional: with node version greater than 4.0.0 will use npm provided by node distribution -->
        <npmVersion>2.15.9</npmVersion>
        
        <!-- optional: where to download node and npm from. Defaults to https://nodejs.org/dist/ -->
        <downloadRoot>http://myproxy.example.org/nodejs/</downloadRoot>
    </configuration>
</plugin>

3、通过maven工程的pom.xml中的nodeDownloadRoot和npmDownloadRoot设置(未验证)

<plugin>
    ...
    <configuration>
        <!-- optional: where to download node from. Defaults to https://nodejs.org/dist/ -->
        <nodeDownloadRoot>http://myproxy.example.org/nodejs/</nodeDownloadRoot>
	<!-- optional: credentials to use from Maven settings to download node -->
        <serverId>server001</serverId>
        <!-- optional: where to download npm from. Defaults to https://registry.npmjs.org/npm/-/ -->
        <npmDownloadRoot>https://myproxy.example.org/npm/</npmDownloadRoot>
    </configuration>
</plugin>

(二)npm包的下载设置

1、通过maven工程的pom.xml中的npm config(未验证)

    <execution>
        <id>npm config</id>
        <goals>
            <goal>npm</goal>
        </goals>
        <configuration>
            <arguments>config set registry https://nexusrepo.com/repository/npmjs/</arguments>
        </configuration>
        <phase>generate-resources</phase>
    </execution>

 2、通过maven的setting.xml中的npm config(未验证)

<execution>
    <id>yarn install</id>
    <goals>
        <goal>yarn</goal>
    </goals>
    <configuration>
         <!-- optional: The default argument is actually
         "install", so unless you need to run some other yarn command,
         you can remove this whole <configuration> section.
         -->
        <arguments>install</arguments>
	<!-- optional: where to download npm modules from. Defaults to https://registry.yarnpkg.com/ -->
	<npmRegistryURL>http://myregistry.example.org/</npmRegistryURL>
    </configuration>
</execution>

 3、通过npm的设置

vi ~/.npmrc

 编辑内容如下

registry=https://your nexus server url:8082/repository/npm-public/
fetch-retry-maxtimeout=9000000
@private:registry=https://your nexus server url:8081/repository/npm-public/
unsafe-perm=true
//your nexus server url:8081/repository/npm-public/:_authToken=NpmToken.9fad776c-2b55-30cb-90f2-f593de9e5cbd


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值