![nginx server_name 带有目录“domain.com/directory1/directory2”](https://linux22.com/image/735611/nginx%20server_name%20%E5%B8%A6%E6%9C%89%E7%9B%AE%E5%BD%95%E2%80%9Cdomain.com%2Fdirectory1%2Fdirectory2%E2%80%9D.png)
我正在尝试使用 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 {