具有IP的不同机器上的两台服务器

时间:2018-07-31 19:37:17

标签: nginx server nextcloud

我的Nextcloud服务器的IP 192.168.0.1运行正常 在另一台IP为192.168.0.2的计算机上安装了collabora在线服务器 对于那些指向同一个公共IP的服务器,我有一个公共IP和两个单独的域

我想做的是使用nginx相应地分配流量。 Nextcloud的配置工作正常:

upstream php-handler {
    server unix:/var/run/php/php7.0-fpm.sock;
}

server {
    listen 80;
    listen [::]:80;
    server_name first.domain.com;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name first.domain.com;
...

现在我要为collabora服务器添加第二个配置:

server {
    listen 80;
    listen [::]:80;
    server_name second.domain.com;
    # enforce https
    return 301 https://$server_name$request_uri;
}


server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name second.domain.com;
    ssl_certificate /etc/ssl/private/server.crt;
    ssl_certificate_key /etc/ssl/private/server.key;
    ssl_password_file /etc/ssl/private/server.pass;


    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass https://second.domain.com;
    }
}

我已将192.168.0.2 second.domain.com添加到主机文件

此服务器也正在运行nginx:

server {
   listen 443 ssl;
   server_name second.domain.com;

    ssl_certificate /etc/ssl/private/server.crt;
    ssl_certificate_key /etc/ssl/private/server.key;
    ssl_password_file /etc/ssl/private/server.pass;
    # static files
    location ^~ /loleaflet {
        proxy_pass https://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # WOPI discovery URL
    location ^~ /hosting/discovery {
        proxy_pass https://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # main websocket
    location ~ ^/lool/(.*)/ws$ {
        proxy_pass https://localhost:9980;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 36000s;
    }

    # download, presentation and image upload
    location ~ ^/lool {
        proxy_pass https://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # Admin Console websocket
    location ^~ /lool/adminws {
        proxy_pass https://localhost:9980;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 36000s;
    }
}

当我打开文件时,collabora窗口在nextcloud中打开空白

nextcloud服务器上的nginx给出响应400。

"GET /lool/https%3A%2F%2Ffirst.domain.com%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F6932_ocqfsn9n2v8v%3Faccess_token%3DOObPuPjPgz7ycgmvNAklYGo1clIANWXU%26access_token_ttl%3D0%26permission%3Dedit/ws?WOPISrc=https%3A%2F%2Ffirst.domain.com%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F6932_ocqfsn9n2v8v&compat=/ws HTTP/1.1" 400 0

所以我不正确地执行了重定向。我需要有关nginx配置的帮助。我知道collabora服务器可以正常工作,因为当我在客户端的hosts文件中设置second.domain.com 192.168.0.2并且没有从nginx重定向时,它就可以正常工作

0 个答案:

没有答案