Ngnix使用笔记

2020-03-05  本文已影响0人  westinyang

常用命令

配置静态网站

server {
    listen       80;
    server_name  mytestdoamin.com;
    location / {
        root d:/html;
        index index.html;
    }
}

配置反向代理

server {
    listen       80;
    server_name  auto.mytestdoamin.com;
    location / {
        proxy_pass http://127.0.0.1:9000;
        proxy_set_header XHost $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

配置静态资源(目录显示)

server {
    listen       80;
    server_name  127.0.0.1;
    location / {
        root d:/static;
        autoindex on;
        autoindex_format html;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
    }
}
上一篇下一篇

猜你喜欢

热点阅读