好吧,現在一直在嘗試這個設置一整天。我無法讓Nginx將azure
給我的域名連接到我的node
docker
容器。docker nginx負載均衡不適用於Azure
我使用Azure
創建一個。 的DNS name
是scout-1j013s34.cloudapp.net
的virtual IP address
是191.237.66.86
我可以ssh
到與ssh [email protected] -p 61777
。我不知道爲什麼我需要指定一個端口?
正在運行Ubuntu 14.04
。 我自己安裝了docker
。
我發現,跟着下面的教程A sample Docker workflow with Nginx, Node.js and Redis
我建,並運行容器,如下圖所示。
這裏是我的nginx.conf
文件
worker_processes 4;
events { worker_connections 1024; }
http {
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
upstream node-app {
least_conn;
server node1:1337 weight=10 max_fails=3 fail_timeout=30s;
server node2:1337 weight=10 max_fails=3 fail_timeout=30s;
server node3:1337 weight=10 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
server_name 191.237.66.86 scout-1j013s34.cloudapp.net www.scout-1j013s34.cloudapp.net;
location/{
proxy_pass http://node-app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
當我輸入http://scout-1j013s34.cloudapp.net/
到瀏覽器地址欄,超時。
更新: 我有EXPOSE 1337
我Dockerfile
揭露1337個端口,每個節點的容器。
對於每個節點容器,我運行docker run -it --name node1 --link mongo:MONGODB -v /home/monty/scout/backend-api/:/scout-sails mlennie/scout-sails bash
將名稱更改爲node2和node3,然後進入每個容器,然後開始sails.js
應用程序sails lift
。
然後,我開始nginx的容器,並將其與命令聯繫到3個容器docker run -d --name nginx -p 80:80 --link node1:node1 --link node2:node2 --link node3:node3 mlennie/nginx
你的Nginx日誌裏有什麼?你有[鏈接](https://docs.docker.com/userguide/dockerlinks/)節點到你的Nginx容器?你有暴露端口1337的節點? – OrangeTux
@OrangeTux我剛剛更新了問題來回答你的問題。我只是將日誌記錄路徑添加到nginx.conf文件。所以我會盡力找到日誌。我相信我確實將節點鏈接到了nginx,並且我在dockerfile的節點上公開了1337端口。 –