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

时间:2016-01-28 01:31:22

标签: nginx config

我在带有Nginx的ubuntu aws服务器上安装了https://jamesrwhite.github.io/minicron/的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;
            }
    }
}

1 个答案:

答案 0 :(得分:1)

目前,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; }

有关详细信息,请参阅thisthis