如何在指定的URL上使用Nginx访问minicron

如何在指定的URL上使用Nginx访问minicron,nginx,config,Nginx,Config,我已经使用Nginx在ubuntuaws服务器上安装了minicron,当我没有在位置中指定目录时,主url会按预期重定向到Cron页面。但是,如果我将“minicron”添加到您下面看到的位置,则会出现“Sinatra不知道这首小曲”错误。我不知所措,谷歌对这两个问题都没有任何帮助。我的主要目标是让minicron加载到一个独立的子域或目录,而不是主url。任何帮助都将不胜感激 http{ ... server { # The port you wan

我已经使用Nginx在ubuntuaws服务器上安装了minicron,当我没有在位置中指定目录时,主url会按预期重定向到Cron页面。但是,如果我将“minicron”添加到您下面看到的位置,则会出现“Sinatra不知道这首小曲”错误。我不知所措,谷歌对这两个问题都没有任何帮助。我的主要目标是让minicron加载到一个独立的子域或目录,而不是主url。任何帮助都将不胜感激

http{

    ...

    server {
           # The port you want minicron to be available, with nginx port 80
           # is implicit but it's left here for demonstration purposes
           listen 80;

            # The host you want minicron to available at
            server_name *.com;

            location /minicron {
                # Pass the real ip address of the user to minicron
                proxy_set_header X-Real-IP $remote_addr;

                # minicron defaults to running on port 9292, if you change
                # this you also need to change your minicron.toml config
                proxy_pass http://127.0.0.1:9292;
            }
    }
}

当前URI
/minicron
正在向上游发送到
http://127.0.0.1:9292/minicron
。您以前的测试可能会命中
http://127.0.0.1:9292/

在向上游发送URI之前,需要重写URI。也许:

location /minicron/ {
    ...
    proxy_pass http://127.0.0.1:9292/;
}
location = /minicron { rewrite ^ /minicron/ last; }

有关详细信息,请参阅和。

页面现在以正确的URL打开,但页面中的所有链接都指向根目录。例如,url.com/jobs应该指向url.com/minicron/jobs,但不能指向。