我最近在学习 Nginx,想配置一下 Nginx 的负载均衡,在同一台机器上启动了两个 tomcat,但使用 localhost 访问时报错:502 Bad Gateway。求 v 友帮忙看一下问题出在哪里?一下是我的配置文件:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
upstream test_A {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
}
server {
listen 80;
server_name localhost;
location / {
# proxy_pass http://127.0.0.1:8080;
proxy_pass http://test_A;
# index home.html;
}
}
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
1
isCyan 2017-11-11 15:35:19 +08:00 via Android
伸手党,又没有日志,光贴配置有什么用。
再说了问题不一定在 nginx 上啊,后端程序有没有启动啊,后端端口有没有正确地被监听啊。 |