尝试在端口8000上激活Raspbian上的nginx网站

时间:2014-02-20 18:07:41

标签: nginx raspberry-pi webserver port raspbian

我设法安装了nginx并在端口81上建立了一个网站(端口80被我的isp阻止)。我正在尝试使用别人的代码在端口8000上启用第二个网站。我的测试网站更简单,因为我只需要:

server  {
        listen 81;
        root /var/www;
        index index.html;
}

如果我在浏览器中转到[http://127.0.0.1:81],我会访问上述网站。

第二个网站有点复杂,我没有让nginx在端口8000上转发请求。我在/ var / www / website2中有第二个网站。如果我输入[http://127.0.0.1:8000],我会收到“找不到页面。但是,如果我输入[http://127.0.0.1:81/website2],那么我会收到该网站。

我有两个站点可用并且已启用,我有一个位于/ etc / nginx /中的website2.cfg文件。

以下是位于sites-available中的website2文件的内容:

server {

    server_name localhost;

    auth_basic "Private Site";
    auth_basic_user_file .htpasswd;

    location / {
        root /var/www;
        index index.html ;
    }

    location /captures/ {
        root /var/www;
    }

    location /api/ {
        proxy_pass http://localhost:8000;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /video {
        proxy_pass http://localhost:8002;
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

以下是位于/ etc / nginx /:

中的website2.cfg文件的内容
[DEFAULT]
# Root directory of the service
root=/var/www/website2

[main]
logFile = /var/log/website2/website2.log

[web]
# Relative URL path to the captured images. Must match what is configurd in nginx, which much
match the directory specified in the [camera] section
capturePath=/captures

# Port on which the web server will listen
port=8000

[camera]

# The number of captured images to retain before pruning old ones
capturesToRetain=100

# The directory to store captured images. Please make sure this matches what was specified in the 
[web] section
captureDir=%(root)s/captures

# The port on which the motion program listens for HTTP commands
motionControlPort = 8001

# The port on which the motion program streams video
motionStreamPort = 8002

如果我可以在8000端口上运行此网站,我应该可以让网站的其余部分正常运行。任何帮助将不胜感激。

0 个答案:

没有答案