尽管位置匹配并且显示了正确的应用程序,但nginx将URL更改为基本路径

时间:2018-07-24 21:04:20

标签: nginx

我有2个Web应用程序和一个在服务器上运行的节点/快捷应用程序。将请求发送到asdf时,基本应用https://asdf.com在基本位置运行。还有一个名为help的辅助Web应用程序,当您请求https://asdf.com/help时运行,而代理服务器应用程序(无关紧要)则响应对https://asdf.com/proxy的请求。

当我点击https://asdf.comhttps://asdf.com/proxy时,一切都会按预期进行,并且我的网址保持不变。但是,当我点击https://asdf.com/help时,我运行了help网络应用程序,但我的URL显示了https://asdf.com并且导航按预期进行了,但是如果刷新站点,我得到的是asdf应用程序应当如此。

我有以下Nginx配置文件:

server {
  ssl on;
  listen              443 ssl;
  server_name asdf.com;
  ssl_certificate     /etc/ssl/certs/asdf.com.crt;
  ssl_certificate_key /etc/ssl/private/asdf.com.key;
  ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers         HIGH:!aNULL:!MD5;
  root /var/www/asdf;

  location / {
    try_files $uri $uri.html $uri/ /help/index.html;
  }

  location /help {
    root /var/www/development/client;
  }

  location /proxy {
    proxy_pass http://localhost:3001;
    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;
  }

  add_header X-Frame-Options SAMEORIGIN;
  add_header X-XSS-Protection 1;
  add_header Content-Security-Policy "frame-ancestors 'self'";
  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
  add_header X-Content-Type-Options "nosniff";
  add_header Referrer-Policy 'strict-origin';
}

如何更改它,以便当我点击https://asdf.com/help时我的URL不会改变?

谢谢!

0 个答案:

没有答案