Nginx / bottle python - request a route to another port

I was looking for an answer, and I find the answer is quite simple, but I could not find it. I think for my ignorance of nginx ...

I have an nginx instance running on localhost: 8080 and my Bottle server listening on localhost: 8081. If I open the addresses from the browser, they work fine, but when I try to access from the application that I run on localhost: 8080, I I can not get the resources generated by the Bottle server.

I need to redirect all calls made in / data / path to the same domain (localhost), but a different port (8081), the one that listens to my bottle server.

Here is the code: Nginx:

server {
    listen       8080;
    server_name  localhost;
    root /Users/Diego/Desktop;

    location / {
        index  index.html index.htm;
    }

    location /data/ {
        proxy_pass http://127.0.0.1:8081;
    }
}

Bottle Server:

@route('/')
def printtest():
    print 'success'
    return 'loaded page'

@route('/<scenename>/data/<filename:path>')
def testMethod(scenename,filename):
    print scenename, filename

run(host='localhost', port=8081, debug=True)

, localhost: 8080, , nginx, , -, /data/directory/filename.json, , , . :

2013/04/16 18:50:52 [error] 3544#10612: *69 CreateFile() "C:/Users/Diego/Desktop/project1/data/directory/directory-varietal.json" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /project1/data/directory/directory-varietal.json HTTP/1.1", host: "localhost:8081", referrer: "http://localhost:8080/project1/"

- , /?

, nginx? print_entry ?

!

EDIT: , ... https://serverfault.com/questions/208656/routing-to-various-node-js-servers-on-same-machine

EDIT: , , , , , . .json Bottle.

location ~* \.(json)$ {
    proxy_pass http://localhost:8081;
}

EDIT: Yeee! ... , , . : : http://wiki.nginx.org/HttpCoreModule#location

:

server {
    listen       8080;
    server_name  localhost;
    root /Users/Diego/Desktop;

    location / {
        index  index.html index.htm;
    }

    location ~* /data/ {
        proxy_pass http://localhost:8081;
    }
}

, - , , .

+5
1

EDIT: Yeee! ... , , . : : http://wiki.nginx.org/HttpCoreModule#location

:

server {
  listen       8080;
  server_name  localhost;
  root /Users/Diego/Desktop;

  location / {
    index  index.html index.htm;
  }

  location ~* /data/ {
    proxy_pass http://localhost:8081;
  }
}

, - , , .

+3

All Articles