在docker中用nginx,要是你的工程部署在外面,就要注意,127.0.0.1是容器里的ip,你要用你的宿主机的ip。不然会报错:
connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: goodcorn.com, request: "GET /api/v1/login/captchaid HTTP/1.1", upstream: "http://127.0.0.1:10088/api/v1/login/captchaid", host: "goodcorn.com", referrer: "http://goodcorn.com/user/login"
正确的配置如下:
upstream goodcorn_api {
server 10.1.118.76:10088 max_fails=5 fail_timeout=10; #这个ip一定不要用127.0.0.1,毕竟我的go代码不跑在容器里
keepalive 20000;
}
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
# For https
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server ipv6only=on;
# ssl_certificate /etc/nginx/ssl/default.crt;
# ssl_certificate_key /etc/nginx/ssl/default.key;
server_name goodcorn.com;
root /var/www/src/github.com/LyricTian/gin-admin/web/dist;
index index.php index.html index.htm;
location /api {
proxy_pass http://goodcorn_api/api;
}
location / {
try_files $uri $uri/ /index.html;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name api.goodcorn.com;
location / {
proxy_pass http://goodcorn_api;
}
location ~ /\.ht {
deny all;
}
}
附上一些docker的操作吧:
docker-compose logs -f nginx
还是docker-compose好用。哈哈。
搜索
标签
study
ab
amap
apache
apahe
awk
aws
bat
centos
CFS
chrome
cmd
cnpm
composer
consul
crontab
css
curl
cygwin
devops
di
docker
docker,docker-compose
ethereum
excel
fiddler
fluentd
framework
front-end
git
gitgui
github
glide
go
golang
gorm
grafana
gzip
ioc
item2
iterm2
javascript
jenkins
jsonp
kafka
laradock
laravel
larval
linux
liunux
log
mac
mac, wi-fi
macos
magento
mariaDB
minikube
mongoDB
msp
mysql
netbeans
nginx
nodejs
nohup
npm
nsq
oracle
php
php-fpm
php7
phpstorm
php扩展
Protobuf
python
redis
scp
server
shell
soap
socket
socket5
sql
sre
ssdb
ssh
ssl
study
sublime
swift
system
td-agent
uml
v2ray
vagrant
vagrnat
vim
vpn
vue
vue.js
webpack
webrtc
websocket
webtatic
windows
windows7
word
wps
xdebug
yarn
yii2
yum
zookeeper
世界国家
互联网
以太坊
分类
前端
小程序
打印机
排序算法
搞笑
权限
粤语
缓存
网络
虚拟机
视频
设计模式
项目管理
热门文章
友情链接