如何使用现有的nginx服务器仅将LionWiki提供给我的LAN?

时间:2014-10-24 19:32:22

标签: nginx owncloud

已安装Owncloud并在我的网络上运行Nginx。我可以从局域网外部访问我自己的云。我想在我的局域网上托管Lionwiki

我想将新的配置文件添加到/etc/nginx/sites-enabled/,以便仅为本地网络上的特定目录提供服务。

我当前的配置:

$ cat /etc/nginx/sites-enabled/default 
# owncloud (ssl/tls)
server {
  listen 443 ssl;
  server_name 192.168.1.10;
  ssl_certificate /etc/nginx/cert.pem;
  ssl_certificate_key /etc/nginx/cert.key;
  root /var/www;
  index index.php;
  client_max_body_size 1000M; # set maximum upload size
  fastcgi_buffers 64 4K;

  # deny direct access
  location ~ ^/owncloud/(data|config|\.ht|db_structure\.xml|README) {
    deny all;
  }

  # default try order
  location / {
    try_files $uri $uri/ index.php;
  }

  # owncloud WebDAV
  location @webdav {
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS on;
    include fastcgi_params;
  }

  # enable php
  location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
    try_files $script_name = 404;
    include fastcgi_params;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param HTTPS on;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_read_timeout 900s; # 15 minutes
  }
}    

1 个答案:

答案 0 :(得分:1)

为您的nginx设置设置两个“托管包”。一个侦听您自己的云的公共主机名,另一个侦听内部主机名和/或内部IP。然后,您可以通过http://the-host-name-you-have.chosen和您的wiki通过\ SERVERNAME或您的内部IP访问您的Owncloud,例如192.168.0.3

您的配置可能看起来像:

server {
            listen       80;
            server_name  SERVERNAME;

            access_log  logs/localhost.access.log  main;

            location / {
                root /var/www/lionwiki;
                index index.html index.htm index.php;
            }

            listen       80;
            server_name  public-host-name;

            access_log  logs/localhost.access.log  main;

            location / {
                root /var/www/owncloud;
                index index.html index.htm index.php;
            }
       }

注意:我不能100%确定该语法是否正确,我通常使用IIS。