我有3个应用:
只有端口80正在运行,其他人只是连接
这是我的代码
端口80.conf
server {
listen 80;
server_name example1.com;
charset utf-8;
access_log /var/log/nginx/access.example1.log;
error_log /var/log/nginx/error.example1.log;
location /static {
alias /usr/src/app/static;
}
location / {
proxy_pass http://example1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
port8001.conf
server {
listen 8001;
server_name example2.com;
charset utf-8;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
access_log /usr/logs/nginx/example1/example2.$year-$month-$day.log;
location / {
root /usr/src/example2;
}
error_page 405 =200 $uri;
}
端口8002
server {
listen 8002;
server_name example3.com;
charset utf-8;
include /etc/nginx/www-allow/example3-allow.conf;
deny all;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
access_log /usr/logs/nginx/example3/example3.$year-$month-$day.log;
location / {
root /usr/src/example3;
}
}
这里有趣的部分是我尝试让port81.conf在端口80上侦听并将port80.conf上的监听到端口8001,这次我的应用程序在port81,conf工作..
所以它只是意味着我的服务器不允许在其他端口访问,例如example.com:8001
如何解决这个问题?
答案 0 :(得分:1)
您是否为端口8001和8002打开了防火墙?
答案 1 :(得分:0)
就我而言,我正在尝试浏览http:// {本地计算机IP地址}:8080,这就是为什么该页面没有显示的原因。令我感到困惑的是,我忘记了需要获取Docker容器的IP地址。
以下是docker命令:
docker exec {docker container id} ipconfig
然后获取IP地址并使用以下格式浏览它:http:// {Docker容器IP地址}:8080