首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx反向代理-只用于/

nginx反向代理-只用于/
EN

Stack Overflow用户
提问于 2015-04-19 00:52:52
回答 2查看 1.3K关注 0票数 0

在我的NAS中,我正在运行seafile作为dropbox/owncloud的替代品。我使用nginx和反向代理来使用/强制SSL为webgui服务。这一切都很好。

现在,我想为在NAS上运行的其他东西设置一些其他的位置(沙发土豆,复式等)。这是我的nginx.conf文件的相关部分:

代码语言:javascript
复制
server {
    listen 80;
    server_name domain.net, 192.168.1.50;

rewrite ^ https://$http_host$request_uri? permanent;    # force redirect http to https

}



server {
        listen 443;
        ssl on;
        ssl_certificate C:/nginx-1.6.3/conf/ssl/ssl-bundle.crt;        # path to your ssl certificate
        ssl_certificate_key C:/nginx-1.6.3/conf/ssl/server.key;    # path to your private key

        server_name domain.net, 192.168.1.50;

        proxy_set_header X-Forwarded-For $remote_addr;

        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
        server_tokens off;

    location /couchpotato {
        proxy_pass http://127.0.0.1:5050;
        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 /cloud {
            fastcgi_pass    127.0.0.1:8000;
            fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
            fastcgi_param   PATH_INFO           $fastcgi_script_name;

            fastcgi_param   SERVER_PROTOCOL        $server_protocol;
            fastcgi_param   QUERY_STRING        $query_string;
            fastcgi_param   REQUEST_METHOD      $request_method;
            fastcgi_param   CONTENT_TYPE        $content_type;
            fastcgi_param   CONTENT_LENGTH      $content_length;
            fastcgi_param   SERVER_ADDR         $server_addr;
            fastcgi_param   SERVER_PORT         $server_port;
            fastcgi_param   SERVER_NAME         $server_name;
            fastcgi_param   HTTPS               on;
            fastcgi_param   HTTP_SCHEME         https;

            access_log      logs/seahub.access.log;
            error_log       logs/seahub.error.log;
        }

        location /seafhttp {
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:8082;
            client_max_body_size 0;
            proxy_connect_timeout  36000s;
            proxy_read_timeout  36000s;
        }

    location /seafmedia {
            rewrite ^/seafmedia(.*)$ /media$1 break;
            root C:/Seafile/seafile-server-4.0.6/seahub;
        }

        location /media {
            root C:/Seafile/seafile-server-4.0.6/seahub;
        }

    }

访问domain.net/cloud (或192.168.1.50/cloud)可以让我毫无问题地访问海洋。访问domain.net为我提供了默认的nginx页面,这是有意义的,因为没有为它定义任何位置。

这个问题将出现在domain.net/Couch土豆上,它会带我去https://domain.net/#couchpotato,而且它不会加载

如果在nginx.conf文件中,我将location /couchpotato {}更改为location / {},那么Couch土豆将正确加载

我很确定我配置nginx的方式有什么问题,但我不知道这是什么,因为这是我第一次使用它

所以我的问题是,为什么使用/couchpotato作为位置不起作用?但使用/做?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-08-04 22:04:03

最后,我改变了海员使用根域(可访问的/),然后设置其他位置,如/couchpotato工作良好

票数 0
EN

Stack Overflow用户

发布于 2015-04-24 14:34:20

我对Couch土豆一无所知,但我的猜测是,它没有配置为从“子目录”提供服务。当您尝试从domain.net/Couch土豆访问它时,传递给它的URI是/couchpotato,我假设它不知道如何处理它。

试一件这样的事情:

1)将Couch土豆配置为从/couchpotato提供服务(这是在实际的the应用程序中完成的)。例如,Wordpress将此称为“站点URL”,它在管理面板中是可配置的。

2)添加一段重写内容,就像您为海员have所做的那样。

代码语言:javascript
复制
rewrite ^/couchpotato(.*)$ $1 break;

这将从URL中删除/couchpotato以进行内部处理,并将预期的URI传递给webapp。

希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29724594

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档