linux下 nginx + tomcat 服务器集群 (2)
来源:互联网 发布:wineskin for mac 编辑:程序博客网 时间:2024/05/01 18:15
在上一节中我们熟悉了linux环境,并成功搭建了nginx服务器和两个tomcat服务器,现在我们需要将他们连接起来。
注意,我们是将tomcat连接到nginx的service虚拟目录,这样nginx即可以做tomcat的负载均衡,同时还兼顾静态页面、图片等处理。
为了简化配置,我们在上一节中,将tomcat的ROOT服务也配置到了相同的目录。
整个系统的编码配置为:utf-8
配置nginx,增加upstream,作为tomcat均衡负载器
vi /usr/local/nginx/conf
错误说明:
403 : 需设置正确的用户名 / 密码。
proxypass 路径设置,如果加后缀: http://localhost/ ,则转发后的路径为: http://localhost:8080/
如果不添加后缀:http://localhost , 则转发后的路径为:http://localhost:8080/service/
#user nobody;
user root root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream localhost {
server localhost:8080;
server localhost:8081;
}
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
root /home/Server/domain;
index index.html index.htm;
}
location /service/ {
root /home/Server/domain/service;
index index.html index.htm index.jsp;
proxy_pass http://localhost/;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 100m;
}
location ~^/(WEB-INF)/ {
deny all;
}
#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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
0 0
- linux下 nginx + tomcat 服务器集群 (2)
- linux下 nginx + tomcat 服务器集群 (1)
- linux下 nginx + tomcat 服务器集群 (3)
- linux下 nginx + tomcat 服务器集群 (4)
- linux下nginx tomcat集群
- linux下nginx+tomcat负载集群实现
- Linux系统下nginx+tomcat搭建集群
- Linux下使用Nginx+Tomcat集群
- Linux+Nginx+Tomcat实现Web服务器的负载均衡集群
- linux环境下通过nginx实现tomcat集群
- linux下tomcat+nginx实现集群和负载均衡
- Windwos下Nginx+Tomcat集群
- linux下安装nginx+tomcat集群实现负载均衡(基础安装)
- Linux下Apache+tomcat搭建负载均衡服务器集群
- Nginx+tomcat负载均衡缓存服务器集群
- 服务器做nginx+tomcat集群+session共享
- Nginx+Tomcat+Redis+NFS搭建服务器集群
- nginx+keepalived+tomcat+memcached服务器集群搭建
- Unity3d接入googleplay内购详细说明(二)
- shell学习笔记:运算符
- 什么是大数据?
- 重定位SVN地址
- Python上的实用技巧
- linux下 nginx + tomcat 服务器集群 (2)
- 巴菲特致股东的一封信:1993年
- Android布局优化。
- 关于shell sort命令的常用操作$
- 进入PE系统后找不到硬盘该怎么办?
- LeetCode #Single Number#
- Android 网络请求方式之HttpClient,GET,POST,PUT请求使用方法
- HDU 1037 Keep on Truckin'
- 8个不可不知的Mac OS X专用命令行工具