现有配置内容
server {
listen 80;
server_name www.abc.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
}
其中, 8080 是 jboss 端口
这样配置完后,当访问 www.abc.com 的时候,会直接跳转 www.abc.com/index.js
那么我要怎么配置才能隐藏 index.js 的?
1
BOYPT 2017 年 4 月 15 日 via Android
你的主页输出个 iframe 代码, iframe 里面开页面。
|
4
Famio 2017 年 4 月 15 日
#3 正解
|
5
fanne OP @laobaozi 指定 root?
这样? server { listen 80; server_name www.abc.com; location / { root /abc/ddd/pro/ proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_redirect off; } } |
6
lmaq 2017 年 4 月 15 日
location / {
root html; index index.html index.htm; } |
7
just1 2017 年 4 月 16 日 via Android
难道不应该是在 jboss 那层配置解决?
这种情况是直接访问 localhost:8080 也会跳 index.js 吧 |
8
Finest 2017 年 4 月 16 日
如果是 war ,那么 web.xml 有 welcome-list 指定
|
9
AstroProfundis 2017 年 4 月 16 日
后端解析 uri 的时候考虑到 /index.js 和 / 用相同的处理方式,然后 nginx 配 rewrite, 或者 try_files
|
11
fanne OP @hand515 在项目中的 web.xml 找到这个 welcome-file-list ,这里指定的么?要怎么指定法?
7 <welcome-file-list> 8 <welcome-file>index.jsf</welcome-file> 9 <welcome-file>index.htm</welcome-file> 10 </welcome-file-list> |
12
Finest 2017 年 4 月 17 日
我 用的 springmvc
<welcome-file-list> <welcome-file>/</welcome-file> </welcome-file-list> 配置成上面那样,然后增加一个 @RequestMapping(value = { "/", "/index" }) public String index(@RequestParam(value = "id", required = false, defaultValue = "1") Long id) { return "forward:/js/jquery-2.1.1.min.js"; } |