nginx转发tomcat详细

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx转发tomcat详细相关的知识,希望对你有一定的参考价值。

目的,在访问nginx的时候,能访问到 tomcat ,这是两个不同的IP ,怎么做,不要百度复制的, 最好详细一点,步骤,
您有Nginx的 rpm 所有安装包吗

参考技术A

nginx+tomcat 有名的配置简单..

我给你贴下我现在一个项目的配置 你自己参考下吧


#user  nobody;
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  75;



    #gzip  on;

    upstream www.vwlms.com 
        server localhost:8080;
    

    
    server 
        listen       80;
        server_name  www.vwlms.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / 
            root   html;
            index  index.html index.htm;
proxy_pass  http://www.vwlms.com;
            proxy_set_header    X-Real-IP   $remote_addr;  
proxy_connect_timeout       1800s;
proxy_read_timeout         1800s;
proxy_send_timeout          1800s;
client_max_body_size 0;
        

        #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;
        

      
    

参考技术B 用 upstream 是可以的。

以上是关于nginx转发tomcat详细的主要内容,如果未能解决你的问题,请参考以下文章

nginx实现tomcat转发

详解https请求Nginx转发tomcat变成http问题

Nginx转发给Tomcat页面时,端口号丢失了

使用Nginx+Tomcat将所有请求都转发到一个页面

nginx 转发请求到多台tomcat

Linux中的请求是如何通过nginx转发到tomcat