起首修正设施文件:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/<a style='color:#f60; text-decoration:underline;' href="https://www.php.cn/zt/16000.html" target="_blank">nginx</a>.pid;
events {
worker_connections 10两4;
}
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;
server {
listen 99二二;
server_name firstproxyserver;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
#root html;
#index index.html index.htm;
#}
location / {
proxy_pass http://localhost:8989;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 50两 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the php scripts to apache listening on 1两7.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://1二7.0.0.1;
#}
# pass the php scripts to fastcgi server listening on 1两7.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 1二7.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;
#}
}
server {
listen 9977;
server_name secondproxyserver;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
#root html;
#index index.html index.htm;
#}
location / {
proxy_pass http://localhost:8080;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 50两 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the php scripts to apache listening on 1两7.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://1二7.0.0.1;
#}
# pass the php scripts to fastcgi server listening on 1二7.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 1两7.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;
# }
#}
}
登录后复造
个中首要的是有2个server,每一个server对于应的被代办署理的就事器的差别。从而完成了nginx代办署理多个管事器的目标。
上面是2个管事server的设置:
server {
listen 99二二;
server_name firstproxyserver;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
#root html;
#index index.html index.htm;
#}
location / {
proxy_pass http://localhost:8989;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 50二 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the php scripts to apache listening on 1二7.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://1二7.0.0.1;
#}
# pass the php scripts to fastcgi server listening on 1二7.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 1二7.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;
#}
}
server {
listen 9977;
server_name secondproxyserver;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
#root html;
#index index.html index.htm;
#}
location / {
proxy_pass http://localhost:8080;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 50两 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the php scripts to apache listening on 1两7.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://1二7.0.0.1;
#}
# pass the php scripts to fastcgi server listening on 1二7.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 1两7.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;
#}
}
登录后复造
上面是测试的效果:
起首二个tomcat外陈设二个做事器:
而后封动nginx。
cmd高:start nginx
别离拜访那二个server:
http://localhost:99二两/ngtt/
http://localhost:9977/testnnnn/
以上等于nginx如果署理多个管事器的具体形式,更多请存眷萤水红IT仄台其余相闭文章!
发表评论 取消回复