nginx域名重定向遇到的问题

来源:互联网 发布:淘宝开店 编辑:程序博客网 时间:2024/05/02 02:15

应客户要求,需要给客户配个域名,然后我们的大牛强哥 建议后台不要配备域名服务器了,这样不安全,一般都是对外的web服务器才配置域名;


结合另外收藏的一个博文安装nginx,然后修改配置文件如下:

---一个域名对应一个conf文件;;;

server {
        listen       80;  ——————————固定端口80
        server_name  A B; ——————逗号间隔一级域名、二级域名

        location / {
            root   /alidata1/tomcat-tes/……;————————服务器绝对路径 根目录
            index  index.html index.htm index.jsp;
            proxy_send_timeout 1200;
            proxy_connect_timeout 1200;

        proxy_pass  http://121.41.*.216*;——————————要比对的地址
        proxy_set_header        X-Real-IP $remote_addr;
                  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                  proxy_set_header        Host $http_host;
        }
    location  /share {————————服务器业务模块二级路径
                  index index.html index.htm index.jsp;
          proxy_send_timeout 1200;
                 proxy_connect_timeout 1200;
                  proxy_pass http://121.4*;
                  proxy_set_header        X-Real-IP $remote_addr;
                  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                  proxy_set_header        Host $http_host;
    }
    
    location  /chao {
                  index index.html index.htm index.jsp;
          proxy_send_timeout 1200;
                 proxy_connect_timeout 1200;
                  proxy_pass http://121.41.4*/;
                  proxy_set_header        X-Real-IP $remote_addr;
                  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                  proxy_set_header        Host $http_host;
    }
    }


修改完了之后要重启nginx 命令:   service nginx restart

如果有必要还重启一下tomcat,



配置第二个域名,同一目录下的另外一个端口登陆地址,则需要另外再建一个conf文件



初识nginx

0 0
原创粉丝点击