'Nginx and Pyramid Obtains Check your Proxy Error

I am trying to use Nginx as a server for a website with Pyramid Framework. I have setup my files based on the documentation here: https://docs.pylonsproject.org/projects/pyramid-cookbook/en/latest/deployment/nginx.html#step-2-starting-pserve. I am not using the optional fragments outlined in the documentation. My nginx.conf file looks like this:

# nginx.conf
user nobody;
worker_processes auto;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
# multi_accept on;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /usr/local/etc/nginx/mime.types;
    default_type application/octet-stream;

    ##Logging Settings
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##Gzip Settings
    gzip on;
    gzip_disable "msie6";

    ##Virtual Host Configs #commented out since these it did not work with these and 
    #they did not exist anyway
    #include /etc/nginx/conf.d/*.conf;
    #include /etc/nginx/sites-enabled/*;# myapp.conf

    upstream myapp-site {
        server 127.0.0.1:port; #I put the actual port number
    }

    server {
        listen 80;

        # optional ssl configuration

        #listen 443 ssl;
        #ssl_certificate /path/to/ssl/pem_file;
        #ssl_certificate_key /path/to/ssl/certificate_key;

        # end of optional ssl configuration

        server_name localhost;

        access_log  /home/example/env/access.log;

        location / {
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $host:$server_port;
            proxy_set_header X-Forwarded-Port $server_port;

            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   60s;
            proxy_send_timeout      90s;
            proxy_read_timeout      90s;
            proxy_buffering         off;
            proxy_temp_file_write_size 64k;
            proxy_pass http://serverIP:port; #I put the IP of the server and correct port
            proxy_redirect          off;
        }
    }
}

Some of the differences are that I wrote the full paths, and I set the domain to localhost instead of a domain like www.thisformat.com. I commented out the ssl block since I want to get nginx setup before I start worrying about encryption. When I use the command $sudo /usr/local/etc/rc.d/nginx onestart, nginx says syntax is ok and successfully runs.

Then my production.ini looks like this

[app:main]
use = egg:my-proj-name#main
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.default_locale_name = en

sqlalchemy.url = mysql://MySQLUsername:MySQLPassword@localhost/MySQLdbName

#retry.attempts = 3

# wsgi server configuration

[alembic]
# path to migration scripts
script_location = /path/to/my-proj-name/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s

[server:main]
use = egg:waitress#main

host = 127.0.0.1
port = %(http_port)s

trusted_proxy = 127.0.0.1
trusted_proxy_count = 1
trusted_proxy_headers = x-forwarded-for x-forwarded-host x-forwarded-proto x-forwarded-port
clear_untrusted_proxy_headers = yes

[loggers]
keys = root, my-proj-name, sqlalchemy, alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console

[logger_my-proj-name]
level = WARN
handlers =
qualname = my-proj-name

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither.  (Recommended for production systems.)

[logger_alembic]
level = WARN
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s

Most of this was default from the cookiecutter template. This runs successfully when I use the command $/path/to/pserve /path/to/production.ini\?http_port=port (again I put the same port #).

All of these files and the commands I issue exist on a server that runs on FreeBSD. The firewall for serverIP:port is open and the requests from my local computer go through (as per the firewall log) but my browser keeps presenting me with "check your proxy or firewall" when I try and open the address. Why isn't it connecting?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source