Ubuntu

nginx 拒絕連接到 wordpress

  • September 25, 2018

我在 ubuntu 18.04 LTS 上有一個 nginx 1.15.3 伺服器,我正在嘗試使用我的 wordpress 網站上的各種外掛來提供網頁或影片的內容,該網站完全位於不同的伺服器/IP 上。但是,當我嘗試在該網站上使用高級 iframe 模組來拉取一個只有影片流的網頁時(它在這里工作:http ://www.tinywebgallery.com/blog/advanced-iframe/free-iframe -checker),它表示 nginx 伺服器的 IP 拒絕連接,這也適用於我嘗試建立的任何其他類型的連接,或者如果我嘗試提取我需要的任何影片流。無論發生什麼都與 nginx 如何與 wordpress 互動有關,反之亦然,我真的不確定。另一台伺服器上的 wordpress 版本是 4.9.8,所以一切都應該是最新的。

這是我的 nginx.conf:

worker_processes  auto;
events {
worker_connections  1024;
}

# RTMP configuration
rtmp {
server {
   listen 1935; # Listen on standard RTMP port
   chunk_size 4096;

   application show1 {
       live on;
       # Turn on HLS
       hls on;
       hls_path /mnt/hls1/;
       hls_fragment 3;
       hls_playlist_length 60;
   }
application show2 {
       live on;
       # Turn on HLS
       hls on;
       hls_path /mnt/hls2/;
       hls_fragment 3;
       hls_playlist_length 60;
   }
application show3 {
       live on;
       # Turn on HLS
       hls on;
       hls_path /mnt/hls3/;
       hls_fragment 3;
       hls_playlist_length 60;
   }
application show4 {
       live on;
       # Turn on HLS
       hls on;
       hls_path /mnt/hls4/;
       hls_fragment 3;
       hls_playlist_length 60;
   }
application show5 {
       live on;
       # Turn on HLS
       hls on;
       hls_path /mnt/hls5/;
       hls_fragment 3;
       hls_playlist_length 60;
   }
application show6 {
       live on;
       # Turn on HLS
       hls on;
       hls_path /mnt/hls6/;
       hls_fragment 3;
       hls_playlist_length 60;
   }
application show7 {
       live on;
       # Turn on HLS
       hls on;
       hls_path /mnt/hls7/;
       hls_fragment 3;
       hls_playlist_length 60;
   }
   application cam01 {
       live on;
       record off;
   }
application cam02 {
       live on;
       record off;
   }
application cam03 {
       live on;
       record off;
   }
application cam04 {
       live on;
       record off;
   }
application cam05 {
       live on;
       record off;
   }
application cam06 {
       live on;
       record off;
   }
application cam07 {
       live on;
       record off;
   }
}
}

http {
sendfile off;
tcp_nopush on;
default_type application/octet-stream;

server {
   listen 80;
   server_name localhost;
   location / {
       # Disable cache
       add_header 'Cache-Control' 'no-cache';

       # CORS setup
       add_header 'Access-Control-Allow-Origin' '*' always;
       add_header 'Access-Control-Expose-Headers' 'Content-Length';

       # allow CORS preflight requests
       if ($request_method = 'OPTIONS') {
           add_header 'Access-Control-Allow-Origin' '*';
           add_header 'Access-Control-Max-Age' 1728000;
           add_header 'Content-Type' 'text/plain charset=UTF-8';
           add_header 'Content-Length' 0;
           return 204;
       }

       types {
           application/dash+xml mpd;
           application/vnd.apple.mpegurl m3u8;
           video/mp2t ts;
       }

       root /mnt/;
       location /index.html {
           default_type "text/html";
       }
       location /testing.html {
           default_type "text/html";
       }
       location /test.html {
           default_type "text/html";
       }
   location /cam01.html {
           default_type "text/html";
       }
   location /cam02.html {
           default_type "text/html";
       }
   location /cam03.html {
           default_type "text/html";
       }
   location /cam04.html {
           default_type "text/html";
       }
   location /cam05.html {
           default_type "text/html";
       }
   location /cam06.html {
           default_type "text/html";
       }
   location /cam07.html {
           default_type "text/html";
       }
   }
}
}

我對 wordpress、nginx 和 serverfault 還是很陌生,所以如果需要更多資訊,請隨時詢問,我會提供。任何幫助將不勝感激,謝謝。

好的,所以聽從 Michael Hampton 的建議來檢查 Web 控制台是否存在網頁上的錯誤。當我在 https 中請求 wordpress 站點時,我發現 nginx 通過 http 而不是 https 提供所有服務,導致某種混合內容錯誤可能對我在各處使用 https 的方式沒有幫助。以正常 http 請求網頁可以正常載入內容。謝謝您的幫助!

引用自:https://serverfault.com/questions/932564