2016-10-01 10 views
0

私はnode.jsアプリとnginxを持っているデジタル海洋のトイレットを持っています。nginx link nodejsアプリをサブドメイン

だから、私はnginxのをインストールし、その後/etc/nginx/sites-available/に私は、次の内容持つapiと呼ばれる新しいファイルを作成しました:私はnginxのをrestaredことを作成した後

server { 
     server_name api.my-website.com; 

     location/{ 
       proxy_set_header X-Real_IP $remote_addr; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
       proxy_set_header Host $proxy_host; 
       proxy_set_header X-NginX-Proxy true; 
       proxy_pass http://127.0.0.1:9000; // this is where the node app lives 
     } 
} 

を私はapi.my-に行く場合website.com私は何も見ません(私のAPIは/にあるランディングページを持っていますが、my-website.com:9000に行くと、api.my-website.com上にあるはずのランディングが見えます)。

私が間違っていることを誰かが説明できますか?

+0

'/ etc/nginx/sites-enabled /'へのシンボリックリンクをインストールしましたか? –

+0

私はそうは思わない、私はチュートリアルに従った、どうすればいい? – Anderson

答えて

0

/etc/nginx/sites-available/apiファイルを/etc/nginx/nginx.confに含めていませんでした。 /etc/nginx/sites-available/api/etc/nginx/nginx.confhttpモジュール内に含める必要があります。その後、nginxを再起動または再読み込みしてください。あなたの/etc/nginx/nginx.confは次のように見えます

http { 
     # other lines for logging, gzip, etc. 
     # other include may here 
     # Your include as following 
     include /etc/nginx/sites-available/api; 
} 
+0

Answer arifのおかげで、私はすでに/ etc/nginx/sites-enabled/*をインクルードしています。 nginx.confで – Anderson

関連する問題