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

CORS : adaptation conf nginx pour Georiviere public #216

Open
xavyeah39 opened this issue Oct 16, 2023 · 1 comment
Open

CORS : adaptation conf nginx pour Georiviere public #216

xavyeah39 opened this issue Oct 16, 2023 · 1 comment
Assignees
Labels
📝 Documentation Improvements or additions to documentation

Comments

@xavyeah39
Copy link

Salut,

Sur l'instance du PNR du Haut-Jura de @thomaspnrhj, nous avions des problème de CORS et de requêtes multi-origines côté Georiviere-public.

J'ai donc modifié la conf nginx par défaut en m'inspirant de celle de Geotrek-admin.
Pouvez-vous contrôler/corriger les adaptations ci-dessous (blocs ou lignes commentés # Fix CORS) afin de les intégrer dans la conf Nginx par défaut de Georiviere-admin ?

Merci !

upstream django {
  server web:8000;
}

# Fix CORS
map $http_origin $allow_origin {
    "~*" $http_origin;
    default "";
}

server {

  listen 80;

  client_max_body_size 10M;

  location / {
    proxy_pass http://django;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Fix CORS
    proxy_redirect off;
    proxy_ssl_server_name on; # Fix CORS

    keepalive_timeout 0; # Fix CORS
    
    # Fix CORS
    location ~ ^/api {
        proxy_pass http://django;
        proxy_read_timeout 300s;
        add_header Access-Control-Allow-Origin $allow_origin;
    }

  }

  location /static/ {
    alias /var/www/static/;
  }

  location /media/ {
    alias /var/www/media/;
    add_header Access-Control-Allow-Origin $allow_origin; # Fix CORS
  }

}
@xavyeah39
Copy link
Author

Bonjour,

Je remonte cette issue car le problème persiste pour le PNR du Haut-Jura.

Voici les logs d'erreurs que l'on reçoit en grand nombre :

[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: '0.0.0.0:8000'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.

Par ailleurs, ce serait bien que l'on puisse proposer un template de conf nginx à l'install et/ou documenter un peut mieux cela dans la doc non ?

Merci de vos retours !

@babastienne babastienne added the 📝 Documentation Improvements or additions to documentation label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📝 Documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants