![](/img/trans.png)
[英]nginx reverse proxy works with port example.com:3001 but not without it
[英]nginx reverse proxy - only works on /
在我的NAS上,我正在運行seafile來替代dropbox / owncloud。 我正在使用nginx和反向代理使用/強制使用SSL來提供webgui。 一切正常。
現在,我想為NAS上運行的其他東西(沙發土豆,plex等)設置其他位置。 這是我的nginx.conf文件的相關部分:
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)可以毫無問題地訪問seafile。 訪問domain.net給了我默認的nginx頁面,這很有意義,因為沒有為該位置定義位置
問題出在domain.net/couchpotato,帶我到https://domain.net/#couchpotato ,它沒有加載
如果在nginx.conf文件中,我將location /couchpotato {}
更改為location / {}
那么oucherpotato將正確加載
我很確定我配置nginx的方式有問題,但是我不確定那是什么,因為這是我第一次使用它
所以我的問題是,為什么將/ couchpotato用作位置不起作用? 但是使用/呢?
我對Couchpotato一無所知,但我猜測它沒有配置為從“子目錄”提供。 當您嘗試從domain.net/couchpotato訪問它時,傳遞給它的URI是/ couchpotato,我認為它不知道如何處理。
嘗試以下方法之一:
1)將Couchpotato配置為從/ couchpotato提供服務(這是在實際的Web應用程序中完成的)。 例如,WordPress將其稱為“站點URL”,並且可以在管理面板中對其進行配置。
2)像添加seafhttp一樣添加重寫。
rewrite ^/couchpotato(.*)$ $1 break;
這將從URL中刪除/ couchpotato進行內部處理,並將預期的URI傳遞到webapp。
希望這可以幫助。
我最終將seafile更改為使用根域(可通過/訪問),然后設置其他位置(如/ couchpotato)可以正常工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.