• nginx反向代理服务器域名解析配置实操


    1、进入nginx目录cd conf:创建文件夹

    sudo mkdir vhost,cd vhost,sudo vim www.fanxing.store.conf,添加如下内容

    server {
    default_type 'text/html';
    charset utf-8;
    listen 80;
    autoindex on;
    server_name www.fanxing.store;
    access_log /usr/local/nginx/logs/access.log combined;
    index index.html index.htm index.jsp index.php;
    #error_page 404 /404.html;
    if ( $query_string ~* ".*[;'<>].*" ){
    return 404;
    }
    location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
    deny all;
    }
    location / {
    #root /product/ftpfile/learning/;

    proxy_pass http://127.0.0.1:8080; //暂时跳到tomcat
    add_header Access-Control-Allow-Origin *;
    }
    }

    保存

    2.重启nginx:sudo ../../sbin/nginx -s rload

    3.配置文件服务器

    server {
    listen 80;
    autoindex off;
    server_name image.fanxing.store;
    access_log /usr/local/nginx/logs/access.log combined;
    index index.html index.htm index.jsp index.php;
    #error_page 404 /404.html;
    if ( $query_string ~* ".*[;'<>].*" ){
    return 404;
    }
    location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
    deny all;
    }
    location / {
    root /ftpfile/;
    add_header Access-Control-Allow-Origin *;
    }
    }

    *****出现404Not Found:image.fanxing.store末尾未加.conf,如果未配置,默认加载nginx/下的nginx.conf

    (nginx: [warn] conflicting server name "image.fanxing.store" on 0.0.0.0:80, ignored,)

    nginx -s reload

    重启nginx报错。

    [warn]: conflicting server name “domain.com” on 0.0.0.0:80, ignored

    检查:server/nginx-1.4.7/conf/vhosts 下的配置文件,应该有重复绑定域名的,找到,修改或删除即可。

    如果image.fanxing.store.conf:autoindex off;就无法访问目录结构,出现403forbidden错误,不可访问;

    *******

  • 相关阅读:
    java.lang.NoClassDefFoundError异常处理
    CMS之promotion failed&concurrent mode failure
    jvm 内存,线程,gc分析
    spring 参数校验
    常用的正则表达式
    《深入理解java虚拟机-高效并发》读书笔记
    ConcurrentHashMap源码分析
    web前端性能调优(二)
    由自动装箱和拆箱引发我看Integer源码
    阅读《effective java-第17条》遇到的问题解决与分享
  • 原文地址:https://www.cnblogs.com/coolcold/p/8335632.html
Copyright © 2020-2023  润新知