2017-02-14 2 views
0

ich habe:Django: dient statischen Abschnitt eines Web-App

  • ein Django Web-App
  • eine separate statische HTML-Website (Blog)

Die statische Seite ist ein separates Verzeichnis Baum.

Ich möchte die statische Website als ein Unterabschnitt der Web-App bedient werden.

Zum Beispiel ist die App auf http://app.com/ und die statisch Website von http://app.com/blog serviert

Hier ist mein /etc/nginx/sites-available/app:

upstream app_server { 
    server 127.0.0.1:9000 fail_timeout=0; 
} 

server { 
    listen 80 default_server; 
    listen [::]:80 default_server ipv6only=on; 

    ... 

    location/{ 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_set_header Host $host; 
      proxy_redirect off; 
      proxy_buffering off; 
      proxy_pass http://app_server; 
    } 
} 
+0

Sie können Setup eine separate Stelle für/Blog und Proxy es Ihre statische Website. –

+0

@BipulJain also ist es nur Nginx-Konfiguration oder muss ich Django berühren? – astreltsov

+0

@astrelsov enthalten Ihre aktuelle Nginx-Konfiguration für Detailantwort, überprüfen Sie meine Antwort –

Antwort

1
server { 
    server_name yourdomain.com; 
    location /blog{ 
    root /path/to/static/html; 
    } 

    location /{ 
    # your django app configuration 
    proxy_pass http://localhost:8000$request_uri; 
    # other configurations 
    } 
} 
+0

funktioniert das perfekt – astreltsov

+0

auch ich habe vergessen, ** nginx ** danach neu zu starten – astreltsov

Verwandte Themen