阿里雲服務器配置開發環境第八章:Centos7.3配置Nginx

Nginx轉發

接着上篇文章說php

cd /usr/local/nginx/conf/vhost
vi ***.***.com.conf

添加如下內容html

server {
    listen 80; # 映射端口
    autoindex on;
    server_name ***.com; # 映射地址
    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 / {
    proxy_pass http://127.0.0.1:8080; # 你要轉發的地址
    add_header Access-Control-Allow-Origin *;
    }
}

Nginx作文件服務器

server {
    listen 80;
    autoindex off;
    server_name ***.com;
    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 / {
        root /ftpfile/; # 你的服務器ftp文件地址
        add_header Access-Control-Allow-Origin *;
    }
}

重啓Nginx

/usr/local/nginx/sbin/nginx -s reload
相關文章
相關標籤/搜索