[英]How can I make lightttp and nginx run on the same Port with different IP addresses (same interface)?
我在RPi上同時運行PiHole,同時在Nginx
代理服務器上運行。 我必須有兩個人的監聽端口80,在這種情況下,pihole必須lighttpd
監聽端口80。為了解決這個問題,我創建了兩個IPS不會忽略,在同一界面(192.168.0.2 192.168.0.3和),我希望將它們都交給lighttpd和Nginx。 我能夠更改lighttpd配置(僅在192.168.0.3上偵聽),我認為一切正常。 然后我的Nginx服務器發生故障,我猜是因為通配符使Nginx偵聽每個IP地址中的端口80。
Nginx當前狀態
Jun 25 00:30:30 sousahost nginx[3040]: nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored
Jun 25 00:30:30 sousahost nginx[3040]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 25 00:30:31 sousahost nginx[3040]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 25 00:30:31 sousahost nginx[3040]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 25 00:30:32 sousahost nginx[3040]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 25 00:30:32 sousahost nginx[3040]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
在這種情況下如何解決我的案件? 我猜最明顯的解決方案是告訴Nginx僅偵聽某個IP地址,但我無法弄清楚(有可能嗎?)。 如何確保Nginx僅列出特定IP?
我的大多數配置都是這樣的:
server {
listen 192.168.1.3:80;
return 301 https://$host$request_uri;
}
server {
listen 443;
server_name ads.sousa.host;
ssl_certificate /etc/nginx/ssl/pi.crt;
ssl_certificate_key /etc/nginx/ssl/pi.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/pi.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://192.168.1.3:80;
proxy_read_timeout 90;
proxy_redirect http://192.168.1.3:80 https://ads.sousa.host/admin;
}
}
另外,我在想好嗎? 在同一接口上創建兩個ip是有效且良好的解決方案嗎? 我願意接受任何建議。
您應該嘗試在listen
指令上使用bind
選項,這樣可以防止nginx
嘗試獲取通配符地址。 有關更多信息,請參見此文檔 。
listen 192.168.0.2:80 bind;
這對多個接口有效。 但不確定在一個接口上使用多個地址是否有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.