立交桥API与nginx

Overpass API with nginx

在: https://wiki.openstreetmap.org/wiki/Overpass_API/Installation 我会读: 仅为 apache 设置 Web API。 Nginx 可以吗?

我正在尝试,但如果我远程询问,我总是发现 405 Not Allowed

nginx.conf

 worker_processes  1;
events {
    worker_connections  1024;
}

http {
    include       mime.types;

    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       8000;
    location /api/ {
        alias /mnt/data/openstreetmap/osm-3s_v0.7.4/cgi-bin/;
    }
    #
    location /cgi-bin/ {
                gzip off;
                root /mnt/data/openstreetmap/osm-3s_v0.7.4/;
                fastcgi_read_timeout 900;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                include /opt/nginx/fastcgi_params;
                fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }

        location / {
            root   /mnt/data/openstreetmap/osm-3s_v0.7.4/html;
            index  index.html index.htm;
        }
    }

}

在本地主机中:

wget --output-document=test.xml http://localhost:8000/api/interpreter?data=%3Cprint%20mode=%22body%22/%3E

--2016-08-14 18:07:38-- http://localhost:8000/api/interpreter?data=%3Cprint%20mode=%22body%22/%3E Petición HTTP enviada, esperando respuesta... 200 OK 经度:1983984 (1,9M) [application/octet-stream] Grabando a:“test.xml”

test.xml 100%[===================================== =================================>] 1,89M --.-KB/s 在 0,004 秒内

2016-08-14 18:07:38 (488 MB/s) - “test.xml” guardado [1983984/19839

在浏览器中(远程客户端): 405 不允许

访问index.html没有问题

写这个

rewrite ^/api/(.+)$ /cgi-bin/ last;

而不是

location /api/ {
    alias /mnt/data/openstreetmap/osm-3s_v0.7.4/cgi-bin/;
}