These are chat archives for cherrypy/cherrypy

18th
Oct 2018
the7erm
@the7erm
Oct 18 2018 03:25
@webknjaz for nginx or cherrypy?
Here's the nginx config.
upstream apps {
   server 127.0.0.1:30118;
}

server {
    listen 80 default_server;
    server_name removed.for.security.reasons
    client_max_body_size 500M;

    access_log /var/log/site/access.log;
    error_log /var/log/site/error.log;

    location / {
        proxy_pass http://apps;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }
}
configuration = {
        'global':{
            'server.socket_host': '0.0.0.0',
            'server.socket_port': 30114,
            'tools.sessions.on': True,
            'tools.sessions.timeout': 1440,
            'tools.sessions.httponly':True,
            'server.thread_pool': 20,
            'server.thread_pool_max': -1,
            'tools.proxy.on': config.tools_proxy_on,
            'tools.proxy.base': config.tools_proxy_base
        },
        '/':{
            'tools.secureheaders.on': False,
            'tools.staticdir.root': config.tools_staticdir_root
        },
        '/js': {
            'tools.staticdir.on':True,
            'tools.staticdir.dir': "js"
        },
        '/css':{
            'tools.staticdir.on':True,
            'tools.staticdir.dir': "css"
        },
        '/img':{
            'tools.staticdir.on':True,
            'tools.staticdir.dir': "img"
        },
        '/jtable':{
            'tools.staticdir.on':True,
            'tools.staticdir.dir': "jtable"
        },
        '/bootstrap':{
            'tools.staticdir.on':True,
            'tools.staticdir.dir': "bootstrap"
        },
        '/main':{
            'tools.staticdir.on':True,
            'tools.staticdir.dir': "main/dist",
            'tools.staticdir.index': "index.html"
        },
        '/favicon.ico':{
            'tools.staticfile.on':True,
            'tools.staticfile.filename': config.favicon
        }
    }
Sviatoslav Sydorenko
@webknjaz
Oct 18 2018 22:31
@the7erm try 'tools.proxy.remote': 'X-Real-IP', this should do what you want.
    cherrypy.request.remote.ip (the IP address of the client) will be
    rewritten if the header specified by the 'remote' arg is valid.
    By default, 'remote' is set to 'X-Forwarded-For'. If you do not
    want to rewrite remote.ip, set the 'remote' arg to an empty string.