Contao-Camp 2024
Ergebnis 1 bis 3 von 3

Thema: [Lösung] Contao Themeplus + nginx + proxy = assets funktionieren nicht.

  1. #1
    Contao-Nutzer
    Registriert seit
    27.09.2011.
    Beiträge
    12

    Standard [Lösung] Contao Themeplus + nginx + proxy = assets funktionieren nicht.

    Hallo zusammen,

    ich bin mit meiner Entwicklungsumgebung auf den nginx umgezogen. Dort hatte ich das Problem,
    dass die proxy.php nicht funktioniert und damit alle CSS + JS Dateien nicht verfügbar sind.

    Lösung:
    Im Contao Wiki steht dazu nur " Unter nginx funktioniert der Proxy nicht richtig." und das eine Weiterleitung notwendig ist.
    Da ich bei Google noch nichts dazu gefunden habe, möchte ich hier meine Konfiguration teilen:

    PHP-Code:
    server {
        
    listen 80;

        
    server_name contao.test;
        
    set $webroot '/Users/username/workspace/contao';
        
    set $errlog "{$webroot}/logs/nginx.log";
        
    set $acclog "{$webroot}/logs/access.log";

        
    root $webroot;

        
    error_log $errlog;
        
    access_log $acclog;

         
    location ~ /(.*\.php)(/.*)$ {
                
    set $script_filename $document_root$1;
                include 
    fastcgi_params;
                
    fastcgi_param SCRIPT_FILENAME $webroot$fastcgi_script_name;
                
    fastcgi_param PATH_INFO $2;
        } 
        
    location / {
                    
    try_files $uri $uri/ /index.php?$args;
                    
    rewrite "^/[a-z]{2}/$" /index.php break;
                    
    rewrite "^/([a-z]{2})$" /$1redirect;
           }

    Meine fastcgi_params enthält zusätzlich zum noch

    PHP-Code:
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
    Ich hoffe es hilft dem ein oder anderen weiter .

    Grüße

    Simon

  2. #2
    Contao-Nutzer
    Registriert seit
    27.09.2011.
    Beiträge
    12

    Standard

    Update:

    Hier gibt es noch eine ausführliches Tutorial, das auch robots.txt usw. umfasst.
    Allerdings fehlt der support für Themeplus.
    Ich verwende nun eine Mischung aus beidem:


    Code:
    server {
           listen 81;
    
    
    	set $webroot '/Users/simonfakir/dev/contao';
        	set $errlog "$webroot/logs/nginx.log";
        	set $acclog "$webroot/logs/access.log";
    
           server_name localhost;
           root $webroot;
           error_log '/$errlog';
           access_log '/$acclog';
    
           index index.php index.html;
    
           location = /favicon.ico {
                    log_not_found off;
                    access_log off;
           }
    
           location = /robots.txt {
                    allow all;
                    log_not_found off;
                    access_log off;
           }
    
           # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
            location ~* \.(tpl|html5|xhtml)$ {
                    deny all;
            }
    
           # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
           location ~ /\. {
                    deny all;
                    access_log off;
                    log_not_found off;
           }
    
    #
    # does not work with themeplus
    #
    
    #       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
    #                expires max;
    #                log_not_found off;
    #       }
    
    #
    # php settings
    #
    
    
            location ~ /(.*\.php)(/.*)$ {
    
                 set $script_filename $document_root$1;
                 include fastcgi_params;
                 fastcgi_param SCRIPT_FILENAME $webroot$fastcgi_script_name;
                 fastcgi_param PATH_INFO $2;
    	     fastcgi_intercept_errors on;
            }
            location / {
                    try_files $uri $uri/ /index.php?$args;
                    rewrite "^/[a-z]{2}/$" /index.php break;
                    rewrite "^/([a-z]{2})$" /$1/ redirect;
            }
    
           location ~ \.php$ {
                    try_files $uri =404;
                    include fastcgi_params;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_intercept_errors on;
           }
    
    
    }
    Zustätzlich eine leicht modifizierte Version der fastcgi_params :

    Code:
    fastcgi_pass unix:/var/run/php-fpm.sock;
    fastcgi_index index.php;
    
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;
    
    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;
    fastcgi_param  HTTPS              $https if_not_empty;
    
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
    
    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;
    Geändert von s.fakir (16.06.2014 um 11:49 Uhr)

  3. #3
    Contao-Urgestein Avatar von Thomas
    Registriert seit
    16.08.2009.
    Ort
    Visselhövede
    Beiträge
    1.947
    User beschenken
    Wunschliste

    Standard

    Theme+ hat damit allerdings wenig zutun!
    Wenn nginx falsch konfiguriert ist, hat das nichts mit irgend welchen Modulen zutun.

    Ich sehe hier nicht mal eine Verwendung als Proxy, es sei denn Du offenbarst uns Deine Konfiguration nicht vollständig.
    Gruß Thomas
    "Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du." Mahatma Gandhi

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •