Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rogue character in my config #154

Closed
josephbisaillon opened this issue Jan 20, 2017 · 3 comments
Closed

Rogue character in my config #154

josephbisaillon opened this issue Jan 20, 2017 · 3 comments
Labels

Comments

@josephbisaillon
Copy link

Not sure if this there is something wrong with my script or something wrong with the generation. But I'm hoping someone can help me figure out where a rogue ';' is coming from.


- hosts: all
  roles:
    - role: jdauphant.nginx
      nginx_http_params:
        - sendfile on
        - access_log /var/log/nginx/access.log
        - |
          map $http_upgrade $connection_upgrade {
            default update;
             '' close;
          }
      # The user to run nginx
      nginx_user: "www-data"

      # A list of hashs that define the servers for nginx,
      # as with http parameters. Any valid server parameters
      # can be defined here.
      nginx_sites:
        default:
          - listen 80
          - listen [::]:80 default_server ipv6only=on
          - listen 443 ssl
          - server_name localhost
          - root "/usr/share/nginx/html"
          - index index.html index.htm
          - |
            location /node/ {
              proxy_pass http://127.0.0.1:9000;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection $connection_upgrade;
            }
          - location / { try_files $uri $uri/ =404; }

Here is the generated nginx.conf

#Ansible managed
user              www-data  www-data;

worker_processes  2;

pid        /var/run/nginx.pid;

worker_rlimit_nofile 1024;


events {
        worker_connections 512;
}


http {

        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        sendfile on;
        access_log /var/log/nginx/access.log;
        map $http_upgrade $connection_upgrade {
  default update;
   '' close;
}
; <------ ROGUE CHARACTER

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

@jdauphant
Copy link
Owner

"- |" and {} isn't managed in nginx_http_params :(

It will work if you place map {} inside nginx_configs :

nginx_configs:
  upgrade:
       - map $http_upgrade $connection_upgrade {
            default update;
             '' close;
          }

We may need to simplify, we can have some confusion if we need to use nginx_http_params or nginx_configs.

@jdauphant jdauphant added the bug label Jan 20, 2017
@josephbisaillon
Copy link
Author

Ah, and it gets added to/conf.d/upgrade.conf I think that works. Thanks!

@wvidana
Copy link
Contributor

wvidana commented Aug 17, 2017

Here some solution to this issue. Not sure if within the global design of this role, but this fix works on our setup, where we also wanted a map {} block on our http params.
#183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants