增加固定IP配置。对应修改readme
This commit is contained in:
@@ -28,17 +28,39 @@ https://gitea.io/en-us/
|
||||
|
||||
6. 执行该sh脚本。注意,可以通过tail -2 /etc/passwd和tail -2 /etc/group 查看新注册用户的uid和gid。如和docker-compose.yml中的不符合则应修改yml文件。
|
||||
|
||||
7. 参照NginxAndLetsencrypt的sample.conf中的注释说明和sampleApp中的compose文件修改docker-compose.yml的网络设置。
|
||||
7. 执行 docker inspect nginxdocker_nginx_1 来确定nginx所在网络名称:
|
||||
|
||||
8. 启动服务
|
||||
|
||||
9. ```
|
||||
docker-compose up -d
|
||||
```
|
||||
"Networks": {
|
||||
"nginxdocker_default": {
|
||||
```
|
||||
|
||||
10. 参照NginxAndLetsencrypt的sample.conf中的注释说明,获取新创建的container的ip,并返回到gitea.conf中将ip填入。
|
||||
8. 执行 docker network inspect nginxdocker_default 来确定一些网络信息:
|
||||
|
||||
```
|
||||
"IPAM": {
|
||||
"Driver": "default",
|
||||
"Options": null,
|
||||
"Config": [
|
||||
{
|
||||
"Subnet": "192.168.16.0/20",
|
||||
"Gateway": "192.168.16.1"
|
||||
}
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
9. 根据上述两点网络相关的信息修改gitea的docker-compose文件中的对应部分,并指定固定IP。
|
||||
|
||||
9. 将需要nginx代理的应用设置的固定IP填入之前的gitea.conf。
|
||||
|
||||
11. 重启nginx的docker容器。
|
||||
|
||||
12. 启动gitea的docker-compose
|
||||
|
||||
13. ```
|
||||
docker-compose up -d
|
||||
```
|
||||
## 使用说明
|
||||
|
||||
- 配置文件在:/srv/gitea/gitea/gitea/conf下的app.ini
|
||||
@@ -48,4 +70,8 @@ https://gitea.io/en-us/
|
||||
|
||||
## 测试环境
|
||||
|
||||
* CentOS Linux release 7.3.1611 (Core)
|
||||
* CentOS Linux release 7.3.1611 (Core)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
@@ -5,6 +5,9 @@ networks:
|
||||
gitea:
|
||||
external:
|
||||
name: nginxdocker_default
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 192.168.16.0/20
|
||||
|
||||
services:
|
||||
server:
|
||||
@@ -19,7 +22,8 @@ services:
|
||||
- DB_PASSWD=Whynotfight?
|
||||
restart: always
|
||||
networks:
|
||||
- gitea
|
||||
gitea:
|
||||
ipv4_address: 192.168.16.15
|
||||
volumes:
|
||||
- ./gitea:/data
|
||||
ports:
|
||||
@@ -37,7 +41,8 @@ services:
|
||||
- MYSQL_PASSWORD=Whynotfight?
|
||||
- MYSQL_DATABASE=gitea
|
||||
networks:
|
||||
- gitea
|
||||
gitea:
|
||||
ipv4_address: 192.168.16.14
|
||||
volumes:
|
||||
- ./mysql/config/my.cnf:/etc/my.cnf
|
||||
- ./mysql/data:/var/lib/mysql
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
|
||||
version: "3.4"
|
||||
|
||||
# setting networks. important when connecting other containers.
|
||||
networks:
|
||||
gitea:
|
||||
external:
|
||||
name: nginxdocker_default
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 192.168.16.0/20
|
||||
|
||||
services:
|
||||
server:
|
||||
@@ -16,10 +19,11 @@ services:
|
||||
- DB_HOST=db:3306
|
||||
- DB_NAME=gitea
|
||||
- DB_USER=gitea
|
||||
- DB_PASSWD=pwd
|
||||
- DB_PASSWD=dbpwd
|
||||
restart: always
|
||||
networks:
|
||||
- gitea
|
||||
gitea:
|
||||
ipv4_address: 192.168.16.15
|
||||
volumes:
|
||||
- ./gitea:/data
|
||||
ports:
|
||||
@@ -29,14 +33,17 @@ services:
|
||||
- db
|
||||
|
||||
db:
|
||||
image: "mysql:5.7.27"
|
||||
image: "mysql/mysql-server"
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=rootpwd
|
||||
- MYSQL_ROOT_PASSWORD=dbrootpwd
|
||||
- MYSQL_USER=gitea
|
||||
- MYSQL_PASSWORD=pwd
|
||||
- MYSQL_PASSWORD=dbpwd
|
||||
- MYSQL_DATABASE=gitea
|
||||
networks:
|
||||
- gitea
|
||||
gitea:
|
||||
ipv4_address: 192.168.16.14
|
||||
volumes:
|
||||
- ./mysql:/var/lib/mysql
|
||||
- ./mysql/config/my.cnf:/etc/my.cnf
|
||||
- ./mysql/data:/var/lib/mysql
|
||||
- ./mysql/init:/docker-entrypoint-initdb.d
|
||||
@@ -23,14 +23,7 @@ server {
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
|
||||
location / {
|
||||
#此处的IP是其他Docker Container的IP。注意:
|
||||
#(1)不需要在compose nginx和letsencrypt的阶段就配置好下面的内容
|
||||
#(2)配置完成后,执行 docker inspect nginxdocker_nginx_1 来确定所在网络名称。如:
|
||||
#"Networks": {
|
||||
# "nginxdocker_default": {
|
||||
#(3)在接下来要运行的应用的docker-compose文件中指定外部网络名称为上述名称。参见sampleApp示例。
|
||||
#(4)用docker inspect命令确定应用的container的IP,填入下方即可。
|
||||
proxy_pass http://172.17.0.1:17000;
|
||||
proxy_pass http://192.168.16.15:3000;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user