【发布时间】:2016-10-24 18:06:47
【问题描述】:
我正在使用 NGINX 网络服务器来代理/绕过基于特定 URI 对某些 JAVA 应用程序(atlassian 产品)的请求,并为我的域的根调用创建了一个默认登录页面,一切都很顺利。但是现在我尝试通过我的站点配置中的特定位置定义来传递另一个静态页面,但我不知道将 css/js/image 传递修复为该页面中的相对路径定义。
这是我的服务器路径结构:
# 01 default landing page
/var/www/df-default/
d css
d js
d img
d fonts
d _external
f index.html
# 02: external source
/var/www/df-default/_external
d css
d js
d img
f impressum.html
f datenschutz.html
这是我当前的 nginx 站点配置:
server {
listen 80;
listen [::]:80;
listen 443 default ssl;
server_name dunkelfrosch.com
#
# ... some ssl stuff here ...
#
root /var/www/df-default;
# default landing page
location / {
try_files $uri $uri/ /index.html;
}
# proxy config for bitbucket application server
location /go/to/bitbucket {
# set 20min proxy timeout
proxy_read_timeout 1600s;
proxy_send_timeout 1600s;
proxy_connect_timeout 1600s;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_pass http://localhost:7990/go/to/bitbucket;
}
# external content 01: static imprint page
# + should available by calling dunkelfrosch.com/show/me/phpugdd/imprint
# - no css,js or image files will delivered using this config
# - I've to insert complete url to css/img/js inside my templates
# and have to config the location block as shown below to deliver the page
location /show/me/phpugdd/imprint {
try_files $uri $uri/ /_external/web/impressum.html;
}
# external content 02: static privacy page
# + should available by calling dunkelfrosch.com/show/me/phpugdd/privacy
# - no css,js or image files will delivered using this config
# - I've to insert complete url to css/img/js inside my templates
# and have to config the location block as shown below to deliver the page
location /show/me/phpugdd/privacy {
try_files $uri $uri/ /_external/web/datenschutz.html;
}
}
我以为我只是提供了一个 location 定义块并重新定义了项目/页面 root 路径,以便任何 $uri被通过 - 但不幸的是它不会。我为这些静态页面所做的每个 css/js/img uri 调用都会强制提供第一个登录页面,而不是相关文件。所以我必须以完整的 url 形式为这些文件添加我的外部链接引用,以“很好”地显示我的静态页面。谁能帮我解决这个问题?
更新
我尝试使用以下配置,同样的问题 - 不会提供 css、js 或图像文件...
location /show/me/phpugdd/privacy {
root /var/www/df-default/_external/web;
index datenschutz.html;
try_files $uri $uri/ /datenschutz.html;
}
location /show/me/phpugdd/imprint {
root /var/www/df-default/_external/web;
index impressum.html;
try_files $uri $uri/ /impressum.html;
}
【问题讨论】:
标签: nginx reverse-proxy