简体   繁体   English

如何配置 nginx 以指向特定的域站点以提供内容?

[英]How to configure nginx to point to specific domain sites to serve up content?

Essentially, I'm trying to serve up some content located at http://local.pubsite.ed/samples/sample01.html with nginx.本质上,我正在尝试使用 nginx 提供位于http://local.pubsite.ed/samples/sample01.html的一些内容。

In order to do so, the directions to the repo instruct to:为此,回购的指示指示:

Use your host file to set this host pointer for two local websites. 
You will need webserver on your system for your environment. 
If you don't have IIS or Apache available, try nginx. 
Webserver configuration is beyond scope of this document.

local.digitru.st 127.0.0.1 local.pubsite.ed 127.0.0.1

Point your webserver and both sites to the root of your source repository. 
Access your site samples at:

http://local.pubsite.ed/samples/sample01.html

I've pointed the nginx root variable, inside of /usr/local/etc/nginx/nginx.conf , to the root of my local repository /Users/zackcarlson/Desktop/Git/dt-cdn/ .我已将/usr/local/etc/nginx/nginx.conf内部的 nginx root变量指向我的本地存储库/Users/zackcarlson/Desktop/Git/dt-cdn/ However, that did not yield anything.然而,这并没有产生任何结果。

So I ended up deleting/uninstalling nginx and starting over following this guide .所以我最终删除/卸载 nginx 并按照本指南重新开始。

I'd appreciate some guidance on how to proceed getting this thing to work.我会很感激一些关于如何继续让这个东西工作的指导。 Thanks in advance!提前致谢!

I've tested the following config to be working with the code from DigiTrust repo我已经测试了以下配置以使用来自DigiTrust 存储库的代码

server {
    listen 80;
    server_name local.pubsite.ed local.digitru.st
    index index.html;
    access_log logs/access.log combined;
    error_log logs/error.log error;

    location / {
        root /Users/zackcarlson/Desktop/Git/dt-cdn/;
    }
}

I can confirm this works, take a look here我可以确认这是有效的,看看这里

However, this is just the start for that project.然而,这只是该项目的开始。 To get it working, i had to:为了让它工作,我必须:

  1. clone the repo克隆回购
  2. follow this doc and run the yarn commands in order.按照这个文档并按顺序运行yarn命令。

grunt command did not worked for me for some reason.由于某种原因, grunt命令对我不起作用。

Hope this helps希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM