nginx server_name 带有目录“domain.com/directory1/directory2”

nginx server_name 带有目录“domain.com/directory1/directory2”

我正在尝试使用 Nginx 作为反向代理,并且具有以下站点配置:

server {
    listen 80;

    listen [::]:80;

    server_name domain.com/directory1/directory2;

    location / {

        proxy_pass http://google.com;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

    }

 }

当我运行 nginx -t 时,我收到以下信息:

nginx: [warn] server name "domain.com/directory1/directory2" has suspicious symbols in /etc/nginx/sites-enabled/default:4

我想知道服务器名称的正确语法是什么,以便我可以在我的 server_name 中实际使用这种 URL?

谢谢

答案1

它应该是这样的:

server_name domain.com;

location /directory1/directory2 {

相关内容