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

Simon發表於2017-08-07

Nginx轉發

接著上篇文章說

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

新增以下內容

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

相關文章