2017-03-23 4 views
0

私はすでにデジタル海洋で2台のサーバを稼働しており、ウェブサーバ用のnginxとアプリサーバ用のnodejをインストールしました。Nodejsリバースプロキシサーバ(nginx)

アプリケーションサーバーの場合: Nodeappディレクトリ:/ var/appdata/myapp/ 4680ポートで実行中のNodejアプリケーション。 ただし、アプリケーションサーバに私が持っているカップルiptablesのオプション(ファイアウォール)

iptablesのオプション私はアプリケーションサーバーのためにした:

*filter 

# Default policy is to drop all traffic 
-P INPUT DROP 
-P FORWARD DROP 
-P OUTPUT DROP 

# Allow all loopback traffic 
-A INPUT -i lo -j ACCEPT 
-A OUTPUT -o lo -j ACCEPT 

# Allow ping. 
-A INPUT -p icmp -m state --state NEW --icmp-type 8 -j ACCEPT 

# Allow incoming SSH, HTTP and HTTPS traffic 
-A INPUT -i eth0 -p tcp -m multiport --dports 22,80,443 -m state --state NEW,ESTABLISHED -j ACCEPT 
-A OUTPUT -o eth0 -p tcp -m multiport --sports 22,80,443 -m state --state ESTABLISHED -j ACCEPT 

# Allow inbound traffic from established connections. 
# This includes ICMP error returns. 
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 

# Log what was incoming but denied (optional but useful). 
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7 

# Allow outgoing SSH, HTTP and HTTPS traffic 
# This is useful because we won't be able to download and install 
# NPM packages otherwise and use git over SSH 
-A OUTPUT -o eth0 -p tcp -m multiport --dports 22,80,443 -m state --state NEW,ESTABLISHED -j ACCEPT 
-A INPUT -i eth0 -p tcp -m multiport --sports 22,80,443 -m state --state ESTABLISHED -j ACCEPT 

# Allow dns lookup 
-A OUTPUT -p udp -o eth0 --dport 53 -j ACCEPT 
-A INPUT -p udp -i eth0 --sport 53 -j ACCEPT 

# Set rate limits for DOS attack prevention (optional) 
# The rates here greatly depend on your application 
-A INPUT -p tcp -m multiport --dports 80,443 -m limit --limit 250/minute --limit-burst 1000 -j ACCEPT 

# Log any traffic which was sent to you 
# for forwarding (optional but useful). 
-A FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7 

COMMIT 

Webサーバのデフォルトの設定ではこれらのすべてではthis-

listen 80 default_server; 
    listen [::]:80 default_server; 

    # SSL configuration 
    # 
    # listen 443 ssl default_server; 
    # listen [::]:443 ssl default_server; 
    # 
    # Note: You should disable gzip for SSL traffic. 
    # See: https://bugs.debian.org/773332 
    # 
    # Read up on ssl_ciphers to ensure a secure configuration. 
    # See: https://bugs.debian.org/765782 
    # 
    # Self signed certs generated by the ssl-cert package 
    # Don't use them in a production server! 
    # 
    # include snippets/snakeoil.conf; 

    root /var/www/html; 

    # Add index.php to the list if you are using PHP 
    index index.html index.htm index.nginx-debian.html; 

    server_name _; 

    location/{ 
      proxy_pass http://10.135.9.223:4680 ; 
      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; 
    } 

のようなものですオプション私はほとんど私が推測するすべてを書き留めますが、何かが見逃した場合は私に教えてください。 ので、ここでの主な問題は、 は、私はhttp://web-server-ip-addressのURLを入力するとき、それは504ゲートウェイは

EDITタイムアウトした応答である: 私は、ファイアウォールを無効にすると問題はありませんが。

+0

ファイアウォールが '10.135.47.36'を言うエラーのこれらのタイプに慣れていない場合にCloudFlareに活用し、nginxの設定ファイルは' 10.135.9.223'氏は述べていますか? Node.jsサーバが(nginxに対して)ローカルで実行されている場合は、 '127.0.0.1'を使用してください。 – robertklep

+0

これは私がちょうどそこにwebservers local-ipのために1223のポートを許可したからです。 –

+0

Ohh私は、2つの別々の(仮想の)サーバ上で動作しているのを見ています。 Webサーバーから10.135.9.223:4680に到達できると確信していますか?また、ポート1223はどこから来ていますか?何を聞いていますか? – robertklep

答えて

0

障害者は、ファイアウォールとあなたが

関連する問題