Nginx https代理配置 + Gitea 私人仓库搭建

#准备工作 创建文件本地存放目录
mkdir -p /opt/container/nginx/config/
mkdir -p /opt/container/nginx/conf.d/
mkdir -p /opt/container/nginx/html/
1.首次启动copy配置文件
docker run --name nginx -p 8088:80 -d nginx

docker cp nginx:/etc/nginx/nginx.conf  /opt/container/nginx/config/nginx.conf

docker cp nginx:/etc/nginx/conf.d/ /opt/container/nginx/

docker cp nginx:/usr/share/nginx/html/ /opt/container/nginx/

docker stop nginx

docker rm nginx
2.上传ssl(key pem)到/opt/container/nginx/ssl/下
3.修改/opt/container/nginx/config/nginx.conf文件
第include /etc/nginx/conf.d/*.conf;下新增监听端口
server {
    listen 9443 ssl;
    charset utf-8;
    server_name owothink.com;

    ssl_certificate /etc/nginx/ssl/owothink.com.pem;
    ssl_certificate_key /etc/nginx/ssl/owothink.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;

    fastcgi_param HTTPS on;
    fastcgi_param HTTP_SCHEME https;

    location / {
        proxy_pass http://172.18.0.1:3000;    #宿主机ip ifconfig查看 docker0 代理gitea端口3000
        proxy_redirect default;
    }
}
创建nginx实例
docker run --name nginx -p 80:80 -p 8443:8443 -p 9443:9443 -p 10443:10443 -p 11443:11443 -v /opt/container/nginx/html/:/usr/share/nginx/html/ -v /opt/container/nginx/config/nginx.conf:/etc/nginx/nginx.conf -v /opt/container/nginx/conf.d:/etc/nginx/conf.d -v /opt/container/nginx/logs/:/var/log/nginx/ -v /opt/container/nginx/ssl/:/etc/nginx/ssl/ --privileged=true -d --restart=always nginx
创建gitea
docker run -d --name=gitea -p 9022:22 -p 3000:3000 -v /opt/container/gitea:/data --restart=always gitea/gitea:latest

浏览器访问https://ip:9443就可以开始初始化gitea了