qq_21150865 2018-02-09 05:46 采纳率: 0%
浏览 989
已结题

求助:nginx反向代理tomcat集群问题

1.我在Vmvare中安装了centos7,并且在centos7中安装了tomcat并在防火墙中开放了访问端口,windows中用浏览器可以正常访问看到黄猫的界面,centos7内部自带的火狐浏览器不能访问,显示链接被重置。求助,可能的原因是什么啊?

2、同时我在centos7中部署了nginx反向代理tomcat集群,部署了两台tomcat,并且能够分别正常访问。我在nginx.conf中添加了代理配置,但是通过nginx服务器访问我的项目显示404,查看日志显示请求的路径是nginx安装目录下的html/test,test是我的项目,这是不是说明我的nginx服务器根本没有去tomcat中请求服务,我的请求到nginx中就终止了,他直接到自己的html目录下面查找我的项目,因为没有我的项目,所以报错,为什么会这样啊?(能确保nginx服务器安装无误,gcc等依赖编译包都正确安装,nginx.conf中的配置也确保正确,求助,还会有什么原因导致这种情况)

(以上两个问题都是在公司内网环境下,通过代理上网的)
这两个问题困扰我好几天了,希望能够得到广大猿友们帮助QAQ

nginx.conf配置文件:

 #user  nobody;

worker_processes 1;

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 tomcat_server{
    server  127.0.0.1:8090;
    server  127.0.0.1:8000;
    server  127.0.0.1:8081;
    server  127.0.0.1:8082;
    ip_hash;

}
server {
listen 80;
server_name localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.html index.htm;
        proxy_pass  http://tomcat_server;
    }
    #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;
#    }
#}

}

 nginx日志:
      1 2018/02/08 12:10:40 [error] 12057#0: *11 open() "/usr/local/nginx/html/test" failed (2: No such file or directory), client: 192.168.200.11, server: localhost, request: "GET /test HTTP/1.1", host: "192.168.200.131"
 2  2018/02/08 12:31:47 [error] 12057#0: *15 open() "/usr/local/nginx/html/test" failed (2: No such file or directory), client: 192.168.200.11, server: localhost, request: "GET /test HTTP/1.1", host: "192.168.200.131"
 3  2018/02/08 12:31:47 [error] 12057#0: *15 open() "/usr/local/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.200.11, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.200.131"
 4  2018/02/08 12:40:13 [error] 12057#0: *17 open() "/usr/local/nginx/html/test" failed (2: No such file or directory), client: 192.168.200.11, server: localhost, request: "GET /test HTTP/1.1", host: "192.168.200.131"
 5  2018/02/11 10:05:04 [notice] 2863#0: signal process started
 6  2018/02/11 10:05:16 [error] 2864#0: *1 open() "/usr/local/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.200.11, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.200.131", referrer: "http://192.168.200.131/"
 7  2018/02/11 10:05:21 [error] 2864#0: *3 open() "/usr/local/nginx/html/test" failed (2: No such file or directory), client: 192.168.200.11, server: localhost, request: "GET /test HTTP/1.1", host: "192.168.200.131"
  • 写回答

6条回答 默认 最新

  • 小钻风寻大观园 2018-02-09 08:31
    关注

    我觉得应该是虚拟机的问题,因为虚拟机网络是通过NAT方式来共享主机的ip的,虚拟机只能和主机进行交互。如果要通过两台虚拟机互相访问的话,要通过主机ip来映射到另一台虚拟机的ip

    评论

报告相同问题?

悬赏问题

  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了