我在我的vm上运行centos7。 我曾经有Apache作为networking服务器,但昨天我用新鲜的ngix安装replace它。 我创build了一个简单的节点应用程序,看看一切正常,猜猜看! 它没有。
我在端口3000上运行应用程序,并使用代理redirect。 但即使控制台告诉我,当我在我的电脑上inputurl时,该应用程序正在工作我得到The page you are looking for is temporarily unavailable. Please try again later. The page you are looking for is temporarily unavailable. Please try again later. 信息。
这里是我的ngixconfiguration:
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name georgegkas.dai.uom.gr; root /usr/share/nginx/html; index index.php index.html index.htm; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } location /blog { proxy_pass http://127.0.0.1:3000; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
这里是我的节点应用程序:
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(3000, '83.212.89.188'); console.log('Server running at http://83.212.89.188:3000/');
所以,如果我使用curl来获取我的虚拟机上的页面内容,我得到正确的输出:
[centos@some-cloud app]$ curl -XGET http://83.212.89.188:3000/ Hello World
如果我使用代理,我得到这个错误页面:
[centos@some-cloud app]$ curl -XGET http://83.212.89.188/blog <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>The page is temporarily unavailable</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> /*<![CDATA[*/ body { background-color: #fff; color: #000; font-size: 0.9em; font-family: sans-serif,helvetica; margin: 0; padding: 0; } :link { color: #c00; } :visited { color: #c00; } a:hover { color: #f50; } h1 { text-align: center; margin: 0; padding: 0.6em 2em 0.4em; background-color: #294172; color: #fff; font-weight: normal; font-size: 1.75em; border-bottom: 2px solid #000; } h1 strong { font-weight: bold; font-size: 1.5em; } h2 { text-align: center; background-color: #3C6EB4; font-size: 1.1em; font-weight: bold; color: #fff; margin: 0; padding: 0.5em; border-bottom: 2px solid #294172; } h3 { text-align: center; background-color: #ff0000; padding: 0.5em; color: #fff; } hr { display: none; } .content { padding: 1em 5em; } .alert { border: 2px solid #000; } img { border: 2px solid #fff; padding: 2px; margin: 2px; } a:hover img { border: 2px solid #294172; } .logos { margin: 1em; text-align: center; } /*]]>*/ </style> </head> <body> <h1><strong>nginx error!</strong></h1> <div class="content"> <h3>The page you are looking for is temporarily unavailable. Please try again later.</h3> <div class="alert"> <h2>Website Administrator</h2> <div class="content"> <p>Something has triggered an error on your website. This is the default error page for <strong>nginx</strong> that is distributed with Fedora. It is located <tt>/usr/share/nginx/html/50x.html</tt></p> <p>You should customize this error page for your own site or edit the <tt>error_page</tt> directive in the <strong>nginx</strong> configuration file <tt>/etc/nginx/nginx.conf</tt>.</p> </div> </div> <div class="logos"> <a href="http://nginx.net/"><img src="/nginx-logo.png" alt="[ Powered by nginx ]" width="121" height="32" /></a> <a href="http://fedoraproject.org/"><img src="/poweredby.png" alt="[ Powered by Fedora ]" width="88" height="31" /></a> </div> </div> </body> </html>
如果我在我的语言环境机器上inputhttp://georgegkas.dai.uom.gr/blog ,则会得到与上面相同的内容:
但是,如果我在我的语言环境机器上inputhttp://georgegkas.dai.uom.gr:3000 ,页面会一直加载,而不会显示任何结果(实际上,在几分钟后,我得到一个错误超时)。
这是怎么回事?