温馨提示×

nginx.conf中的server块如何配置

小樊
97
2024-08-14 01:20:36
栏目: 编程语言

在nginx.conf中的server块配置如下:

server {
    listen 80;
    server_name example.com;

    location / {
        root /var/www/html;
        index index.html;
    }

    location /api {
        proxy_pass http://localhost:3000;
    }
}

这个例子中,server块设置监听端口为80,server_name为example.com。在location /指令中配置了根目录和默认首页文件,同时在location /api中配置了反向代理到本地的3000端口。根据实际需求,可以根据需求配置更多的location和指令。

0