Build nginx gogs in docker, both in the same docker network.
Test conditions:
- Gogs can be accessed via IP+ port
- Nginx can be started and can proxy another html page and be accessed through a secondary domain name.
Question:
Gogs cannot be accessed through the secondary domain name. Error reporting:502 Bad Gateway nginx/1.15.6
The domain name in the code is replaced by # domain name
error.log
2018/11/15 06: 53: 21 [Error] 5 # 5: * 1 Connect () Failed (111: Connection Used) While Connecting to Upstream, Client: 14.153.77.141, Server: # Domain Name. Request: "get/http/2.0", upstream: "http://172.18.0.3: 10080/",host: "# domain name"
nginx.config
user nginx;
worker_processes auto;
error_log /etc/nginx/err/error.log;
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
default.conf
server {
listen 80;
Server_name # normal domain name;
return 301 https://$server_name$request_uri;
}
server{
listen 443 ssl http2;
Server_name # normal domain name;
Ssl_certificate # normal key;
Ssl_certificate_key # normal key;
ssl_session_timeout 10m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:! aNULL:d! MD5:! RC4:! DHE;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_pass http://gogs:10080/;
proxy_redirect default;
}
access_log /etc/nginx/err/gogs.log;
}
App.ini of gogs
[server]
DOMAIN = http://127.0.0.1
HTTP_PORT = 3000
ROOT_URL = http://127.0.0.1:10080/
DISABLE_SSH = false
SSH_PORT = 10022
START_SSH_SERVER = true
OFFLINE_MODE = false
ENABLE_GZIP = true
Strange, why should nginx write
proxy_pass http://gogs:3000;
In this way.
Resolved