我学习了本教程(https://medium.com/@atishub.vaishnaw/deploying-hosting-a-node-app-in-aws-ec2-instance-part-1-9b6afcc8be6(,并在需要的地方调整代码,但nginx没有做好它的工作。它只是显示了欢迎使用nginx!页这是我的配置文件内部的路径/etc/nginx/mywebsite.extension:
server {
listen 80;
listen [::]:80;
root /var/www/carrating.ml/html;
index index.html index.htm index.nginx-debian.html
server_name carrating.ml www.carrating.ml;
location / {
proxy_pass http://localhost:1337;#whatever port your app run
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;
}
}
我正在1337 端口的nodejs上运行web服务器
将文件从/etc/nginx/mywebsite.extension
位置移动到/etc/nginx/sites-available/carrating.ml.conf
。
sudo mv /etc/nginx/mywebsite.extension /etc/nginx/sites-available/carrating.ml.conf
然后使用创建指向/etc/nginx/sites-enabled/
目录内文件的符号链接
sudo ln -s /etc/nginx/sites-available/carrating.ml.conf /etc/nginx/sites-enabled/
重新启动nginx服务器:
# Test NGINX config
sudo nginx -t
# Restart NGINX
sudo service nginx restart