[英]Nginx not listening to other ports only port 80
我有 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;
}
}
端口8001.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)中訪問
如何解決這個問題?
您是否為端口 8001 和 8002 打開了防火牆?
就我而言,我試圖瀏覽 http://{Local machine IP Address}:8080,這就是頁面未顯示的原因。 令我困惑的是,我忘記了我需要獲取 Docker 容器的 IP 地址。
這是 docker 命令:
docker exec {docker container id} ipconfig
然后獲取 IP 地址並使用以下格式瀏覽它:http://{Docker 容器 IP 地址}:8080
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.