我有文件,/Users/me/myproject我想http://stuff.dev/something使用简单的nginx配置为他们服务.在/Users/me/myproject文件夹中是这样的:
index.html
scripts/
app.js
styles/
style.css
Run Code Online (Sandbox Code Playgroud)
所以,我真的希望能够访问http://stuff.dev/something,http://stuff.dev/something/scripts/app.js等等.
在我的nginx conf中我有这个:
server {
listen 80;
server_name stuff.dev;
location /something {
index index.html;
root /Users/me/myproject;
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用(如果我尝试转到上面的URL,我得到404),但是如果我尝试完全相同的设置但使用location / {而不是location /something {,它可以正常工作.我如何静态地提供这个文件目录,但是在路径而不是在根位置?我是否必须将文件放在名为"something"的文件夹中/Users/me/myproject/something才能使用?如果是这样的话还有办法吗?
Nat*_*ate 19
我在我的VPS上尝试了这个,并使用该alias命令为我工作:
server {
listen 80;
server_name something.nateeagle.com;
location /something {
alias /home/neagle/something;
index index.html index.htm;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20606 次 |
| 最近记录: |