nginx配置站点默认首页,伪静态JSP和多Server反向代理

#虽然都是location但是是有区别的

#设置首页

location = / {
   proxy_pass http://127.0.0.1/site/eshop/home.html;
   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 / {
   #root /site/eshop/;
   #index home.html;
   proxy_pass http://127.0.0.1:7001;
   rewrite (.*)\.html$ $1.jsp;

}

完整设置示例

server {
listen 80;
server_name 115.28.x.x;

#charset koi8-r;

#access_log logs/host.access.log main;

location = / {
proxy_pass http://127.0.0.1/site/eshop/home.html;
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 / {
#root /site/eshop/;
#index home.html;
proxy_pass http://127.0.0.1:7001;
rewrite (.*)\.html$ $1.jsp;

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache‘s document root
# concurs with nginx‘s one
#
#location ~ /\.ht {
# deny all;
#}
}

时间: 2024-08-01 15:16:11

nginx配置站点默认首页,伪静态JSP和多Server反向代理的相关文章

Apache站点默认首页设置

Apache的默认首页为index.html,当我们需要改首页文件或者增加首页文件时,可以在httpd.conf文件中增加配置语句. httpd.conf首页文件默认配置语句如下: <IfModule dir_module> DirectoryIndex index.html </IfModule> 如果我们需要增加首页文件xxx.htm时,可以在DirectoryIndex index.html下增加加一行语句DirectoryIndex xxx.htm,优先级从上到下. 例如我

Nginx配置站点适配PC和手机

考虑到站点的在多种设备下的兼容性,有非常多站点会有手机版和电脑版两个版本号.訪问同一个站点URL,当服务端识别出用户使用电脑訪问.就打开电脑版的页面,用户假设使用手机訪问,则会得到手机版的页面. 1.推断client的设备类型 要想让站点适配PC和手机设备,首先要能做出准确的推断.HTTP请求的Header中的User-Agent能够区分client的浏览器类型.能够通过User-Agent来推断client的设备. 不管是PC还是手机,因为操作系统.浏览器的多样性,自己来实现这个推断并不eas

五、Nginx多Server反向代理配置

Nginx强大的正则表达式支持,可以使server_name的配置变得很灵活,如果你要做多用户博客,那么每个用户拥有自己的二级域名也就很容易实现了. server_name的匹配顺序 Nginx中的server_name指令主要用于配置基于名称虚拟主机,server_name指令在接到请求后的匹配顺序分别为: 1.准确的server_name匹配,例如: 1 server { 2 listen 80; 3 server_name www.ooxx.com; 4 ... 5 } 2.以*通配符开始

Nginx多Server反向代理配置

Nginx强大的正则表达式支持,可以使server_name的配置变得很灵活,如果你要做多用户博客,那么每个用户拥有自己的二级域名也就很容易实现了. 下面我就来说说server_name的使用吧: server_name的匹配顺序 Nginx中的server_name指令主要用于配置基于名称虚拟主机,server_name指令在接到请求后的匹配顺序分别为: 1.准确的server_name匹配,例如: server { listen 80; server_name ssdr.info www.s

Nginx配置:防盗链、访问控制、解析PHP以及代理

一.Nginx防盗链 防盗链是指一个网站的资源(图片或附件)未经允许在其它网站提供浏览和下载,尤其热门资源的盗链,对网站带宽的消耗非常大,设置防盗链以节省资源. 1.修改虚拟主机配置文件 [[email protected] vhost]# vim linuxtest.conf server { listen 80; server_name linuxtest.com; index index.html index.htm index.php; root /data/wwwroot/linuxt

92.Nginx配置:防盗链、访问控制、解析PHP以及代理

一.Nginx防盗链 防盗链是指一个网站的资源(图片或附件)未经允许在其它网站提供浏览和下载,尤其热门资源的盗链,对网站带宽的消耗非常大,设置防盗链以节省资源. 1.修改虚拟主机配置文件 [[email protected] vhost]# vim linuxtest.conf server { listen 80; server_name linuxtest.com; index index.html index.htm index.php; root /data/wwwroot/linuxt

thinkphp怎么修改配置进入默认首页

thinkphp文件夹下config 里面有个convention.php文件 里面有三个配置'DEFAULT_MODULE' => 'Home', // 默认模块'DEFAULT_CONTROLLER' => 'Index', // 默认控制器名称'DEFAULT_ACTION' => 'index', // 默认操作名称改掉这三个就可以改默认的首页

Nginx配置站点https

step 1: 检查nginx的编译参数 使用nginx -V可以查看,如果编译参数中包含http_ssl_module,可以继续下一步操作,如果没有,则需要从新编译. step 2: 申请证书 目前,阿里云等云平台可以申请一定时间的免费证书,这里大家可以自行找下,不再多说 step 3: 配置nginx.conf server { listen 443; server_name hae.top; ssl on; ssl_certificate /usr/local/nginx/key/2146

eclipse中配置tomcat后,运行jsp时出现Server Tomcat v7.0 Server at localhost failed to start.

最近在进行jsp开发学习,在配置上还是遇到很多问题. 在连接好数据库后,写了第一个jsp测试页面,结果在运行eclipse中运行toamcat时出现了错误提示:Server Tomcat v7.0 Server at localhost failed to start. 在cmd中运行   java   //正常 在cmd中运行   javac    //正常 运行tomcat的bin文件下的startup正常启动,唯独在eclipse中出现Server Tomcat v7.0 Server a