Java 如何在nginx conf文件中指定uri?

Java 如何在nginx conf文件中指定uri?,java,nginx,Java,Nginx,我试图理解以下nginx conf文件()。我应该用什么替换@example\u app server { listen 80; server_name example.com; rewrite ^(.+?)/?$ http://www.example.com$1 permanent; } server { listen 80; server_name www.example.com; root /var/www/example.com/public_html;

我试图理解以下nginx conf文件()。我应该用什么替换
@example\u app

server {
  listen 80;
  server_name example.com;
  rewrite ^(.+?)/?$ http://www.example.com$1 permanent;
}

server {
  listen 80;
  server_name www.example.com;
  root /var/www/example.com/public_html;

  location / {
    try_files $uri @example_app;
  }

  location @example_app {
    proxy_pass http://localhost:5000;
  }

}

编辑

我把配置文件改成了这个。这样更好吗?我改编自。我还将我的域和ip地址添加到
/etc/hosts

 upstream ring {
        server 127.0.0.1:8080 fail_timeout=0;
}

server {
        root /usr/share/nginx/html;

        server_name localhost;

        location / {
                try_files $uri $uri/ @ring;
        }

        location @ring {
                proxy_redirect off;
                proxy_buffering off;
                proxy_set_header Host $http_host;
                proxy_pass http://ring;
        }

        location ~ ^/(assets|images|javascripts/stylesheets|swfs|system)/ {
        expires     max;
        add_header  Cache-Control public;
        }


如果你不想,你不需要用任何东西替换
@example\u app
。它只是一个命名的位置,可以轻松地更改为
@任何内容。您只需确保如果使用
try\u files
引用命名位置,则需要在配置文件中定义相同的位置

Reddit上的评论很好地解释了配置,但要重申:

1) 第一个服务器块将所有请求从example.com重定向到www.example.com 2) 第二个服务器块捕获对www.example.com的请求 3)
location/
块捕获此服务器块内的所有请求,并尝试
try\u files
中的选项列表-首先尝试加载该路径上的任何匹配文件,否则使用命名的location@example\u app
4)
location@example\u app
块是一个命名位置,代理将请求传递到同一服务器上的端口5000。

很抱歉,这让我很困惑。同时,我更改了配置文件以匹配前面的答案。我编辑了我的问题,你能看一下吗?