2016-08-21 78 views
0

我正在嘗試安裝react.js應用程序並使用pm2包來運行服務器。無法爲Node.js正確配置Nginx應用程序

/etc/nginx/sites-available/default文件的內容是:

server { 
    listen 80; 

    server_name my.domain.name; 

    location/{ 
     proxy_pass http://127.0.0.1:8080; 
     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection 'upgrade'; 
     proxy_set_header Host $host; 
     proxy_cache_bypass $http_upgrade; 
    } 
} 

我的反應服務器端口8080上運行,因爲當我做curl localhost:8080從服務器,我得到了適當的響應。此外,與curl localhost也我得到正確的反應服務器的迴應。

但是,當我在瀏覽器中訪問my.domain.name時,我只是得到默認的nginx頁面,表示它已成功安裝。

我在這裏錯過了什麼?

編輯:

新增Reactjs應用程序的server.js文件:

var webpack = require('webpack'); 
var WebpackDevServer = require('webpack-dev-server'); 
var config = require('./webpack.config'); 

new WebpackDevServer(webpack(config), { 
    publicPath: config.output.publicPath, 
    hot: true, 
    historyApiFallback: true 
}).listen(8080, 'localhost', function (err, result) { 
    if (err) { 
    return console.log(err); 
    } 

的console.log( '在http://localhost:8080/聽'); });

+0

該問題與反應或任何形式的實際服務器應用程序無關。這是純粹的nginx配置問題,因此問題的標題是誤導性的。 –

+0

@OlegSklyar更新標題 – tekina

+0

檢查您的主機條目設置天氣來自您的主機的請求使用localhost映射:8080 –

回答

相關問題