我同时使用NodeJS和Nginx。 我设法在此处提供我的网站:http://beers.wellingguzman.com。但是所有的静态文件都没有直接在这里提供:http://beers.wellingguzman.com/css/app.css正如它应该的那样,但它在这里:http://beers.wellingguzman.com:3001/css/app.css使用端口。
虽然这在localhost上完美运行。这是存储库:https://github.com/WellingGuzman/Beers
这是我的nginx配置
upstream app_beers {
server 127.0.0.1:3001;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
access_log /var/log/nginx/beers.log;
root /var/public_html/beers;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name beers.wellingguzman.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 $http_host;
proxy_set_header X-NginX-Proxy true;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
proxy_pass http://app_beers;
proxy_redirect off;
}
希望这是了解可能出现的问题所需的全部信息。
感谢。