问题描述
我一直在尝试找出如何将服务器指向我的静态页面,该页面将其存储在我的云服务器中的某个位置.另外,我正在使用NodeJs作为后端.
I have been trying to figure out how to point the server to my static page that i store it up somewhere in my cloud server. Also, i am using NodeJs as my backend.
我的老问题:它不是指向myProjectX index.html,而是指向Nginx默认网页"Welcome to Nginx!".我不知道为什么;/
My old problem: It's not point to my myProjectX index.html instead it points to the Nginx default web page "Welcome to Nginx!". I cannot figure out why ;/
更新
我的新问题:在完成此新配置后,它使我指向404页面,而不是指向我的index.html
My new problem: After this new configuration that i did, it points me to a 404 page instead of pointing to my index.html
此外,在第20行中,当我出于调试目的而运行sudo nginx -t时,它给我一个重复的"/"错误
Also, in the line 20, it gives me an error of duplicate "/" when i run sudo nginx -t for debugging purpose
`nginx: [emerg] duplicate location "/" in /etc/nginx/sites-enabled/default:20 `
这是我的Nginx配置文件...
here's my Nginx configuration file...
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name www.andii90s.com;
root /home/andy/www/myProjectX/app;
index index.html index.htm;
location / {
proxy_pass http://10.137.10.140: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;
}
location / {
#Line 20
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/andy/www/myProjectX/app;
}
}
推荐答案
引用此博客 http://caffeinecodes.blogspot.in/2017/02/nginx-settings.html
server {
listen 80;
server_name test.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /Users/Afxal/workspace/test_project/static/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8000;
}
}
这篇关于如何设置nginx配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!