Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants