我一直在努力解决这个问题,但无济于事。我想要实现的是将我的网址从http://subdomain.domain.com:9091/transmission/web/隐藏到http://subdomain.domain.com/tr/
这是我到目前为止所得到的
nginx default.conf
location /tr/ {
proxy_read_timeout 300;
proxy_pass_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9091/transmission/web/;
proxy_redirect off;
}
传输网络界面确实显示但css,jss和img都是404.有没有解决方法?
提前致谢。
答案 0 :(得分:4)
upstream transmissionweb {
server localhost:9091;
}
server {
server_name www.example.com;
root /var/www/www.example.com;
access_log /var/log/nginx/www.example.com.access.log;
error_log /var/log/nginx/www.example.com.error.log;
location /transmission {
proxy_pass http://transmissionweb;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
答案 1 :(得分:3)
我使用以下配置代理传输。 请注意“location / torrent /” - 我将传输中的默认“rpc-url”设置从“/ transmission /”更改为“/ torrent /”。
这适用于Ubuntu 12.04.2 LTS下的nginx / 1.2.7和传输2.51。
upstream transmission {
server 127.0.0.1:9091;
keepalive 4;
}
server {
listen 80;
server_name localhost;
location /torrent/ {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass_header X-Transmission-Session-Id;
location /torrent/rpc {
proxy_pass http://transmission;
}
location /torrent/web/ {
proxy_pass http://transmission;
}
location /torrent/upload {
proxy_pass http://transmission;
}
location /torrent/web/style/ {
alias /usr/share/transmission/web/style/;
}
location /torrent/web/javascript/ {
alias /usr/share/transmission/web/javascript/;
}
location /torrent/web/images/ {
alias /usr/share/transmission/web/images/;
}
}
}