zoukankan      html  css  js  c++  java
  • 2017.7.1 nginx*服务器域名解析配置(已验证可使用)

    下载地址:http://learning.happymmall.com/

     前提:ftpserver已经开启,并且设置为:

    1.获得安装文件

     2.修改配置文件

    2.1 修改conf/nginx.conf

    引入此文件夹内的配置文件。

     

    2.2 vhost文件夹

    新建文件夹:vhost和相关配置文件。

     2.3 文件夹转发 vhost/image.imooc.com

    注意: root C:ftpfileimg; 千万不要多加一个变为root C:ftpfileimg;

     1 server { 
     2     listen 80; 
     3     autoindex off; 
     4     server_name image.imooc.com; 
     5     access_log c:/access.log combined; 
     6     index index.html index.htm index.jsp index.php; 
     7     #error_page 404 /404.html; 
     8     if ( $query_string ~* ".*[;'<>].*" ){ 
     9         return 404; 
    10     } 
    11     location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* { 
    12         deny all; 
    13     } 
    14     location / { 
    15         root C:ftpfileimg; 
    16         add_header Access-Control-Allow-Origin *; 
    17     } 
    18 }

    并在路径C:ftpfileimg中添加一个图片:

    2.4  端口转发 vhost/tomcat.imooc.com

     1 server { 
     2     listen 80; 
     3     autoindex off; 
     4     server_name tomcat.imooc.com; 
     5     access_log c:/access.log combined; 
     6     index index.html index.htm index.jsp index.php; 
     7     #error_page 404 /404.html; 
     8     if ( $query_string ~* ".*[;'<>].*" ){ 
     9         return 404; 
    10     } 
    11      
    12     location / { 
    13         proxy_pass http://127.0.0.1:8080; 
    14         add_header Access-Control-Allow-Origin *; 
    15     } 
    16 }

    2.5 修改本机C:WindowsSystem32driversetchost

    在尾部添加:

    3. 启动nginx

    -t的意思是,启动并检查conf是否正确。

    如果修改了nginx的配置文件,则reload一下即可。

    4. 验证成功

    4.1 测试文件夹转发

     访问image.imooc.com

    访问image.imooc.com/1.png,出现1.png,则表示文件夹转发成功。

    4.2 测试端口转发

    开启tomcat,访问localhost:8080,出现tomcat首页表示tomcat开启成功。

    访问tomcat.imooc.com,出现nginx的首页则表示转发成功。

  • 相关阅读:
    数据仓库与数据挖掘的一些基本概念
    System.currentTimeMillis();
    html练习(3)
    HDU 1556 Color the ball【算法的优化】
    ubuntu12.04 安装配置jdk1.7
    java中的switch用String作为条件
    oracle中 connect by prior 递归算法
    C#复习题
    AngularJS:Http
    AngularJS:Service
  • 原文地址:https://www.cnblogs.com/lyh421/p/7103684.html
Copyright © 2011-2022 走看看