• nginx反向代理


    一般企业服务器只有一台,我们需要在一台服务器上放置多个网站,需要多个tomcat 把不同的网站对应的端口不一样,这是需要反向代理。

    第一步:安装两个tomcat,分别运行在80808081端口。

    第二步:启动两个tomcat

    第三步:反向代理服务器的配置

    upstream tomcat1 {

    server 192.168.25.148:8080;

        }

        server {

            listen       80;

            server_name  www.sina.com.cn;

            #charset koi8-r;

            #access_log  logs/host.access.log  main;

            location / {

                proxy_pass   http://tomcat1;

                index  index.html index.htm;

            }

        }

        upstream tomcat2 {

    server 192.168.25.148:8081;

        }

        server {

            listen       80;

            server_name  www.sohu.com;

            #charset koi8-r;

            #access_log  logs/host.access.log  main;

            location / {

                proxy_pass   http://tomcat2;

                index  index.html index.htm;

            }

        }

    第四步:nginx重新加载配置文件

    第五步:配置域名(测试,正常企业的域名会存在多以不用)

    hosts文件中添加域名和ip的映射关系  

    C:WindowsSystem32driversetc

    虚拟机ip www.sina.com.cn

    虚拟机ip www.sohu.com

     好现在就可以使用这两个域名了。

  • 相关阅读:
    xargs 原理&使用
    django1.7 HTML模板中{%url%}的使用
    2017/2/27
    对django rest_framework的个人理解
    restful api设计理念
    web service的理解
    如何重启mysql服务
    Navicat中MySQL server has gone away错误怎么办【转载】
    Why getting this error “django.db.utils.OperationalError: (1050, ”Table 'someTable' already exists“)”
    转:android service总结
  • 原文地址:https://www.cnblogs.com/changqijing/p/8392718.html
Copyright © 2020-2023  润新知