Ich entwickle ein Projekt mit Symfony2, Nginx.Symfony2 Nginx auth_basic config nicht öffnen web assests
Projekt befindet sich in meiner Subdomain wie developing_site.mysite.com.
Ich möchte den Zugriff auf diese Subdomain ohne Authentifizierung beschränken. Nicht nur für Dev- und Config-Dateien, sondern auch für die Produktion.
Also ich habe auth_basic Komponente Nginx Config-Datei in location/
Sektor in Nginx Config hinzugefügt, die von Symfony offizielle Website empfohlen wird. Als Ergebnis, vor dem Laden der Seite Server fragt Authentifizierung und lädt alles außer für alle Dateien speichert in /web
Verzeichnis wie Bilder, js, css und so weiter. Daher wird der gesamte Inhalt von .php verarbeitet, jedoch ohne Stil und dynamische Funktionalität.
Also, wie kann ich dieses Problem lösen? Was mache ich falsch?
Nginx Konfiguration sieht wie folgt aus:
server {
listen {MyServerIp};
server_name developing_site.mysite.com;
root /var/www/developing_site/web;
index index.php index.html index.htm;
location/{
try_files $uri /app.php$is_args$args;
auth_basic "Restricted Content";
auth_basic_user_file var/www/developing_site/.lock/.htpasswd;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
Sie DEV und ART Umgebung mischen, können Sie nicht logisch 2-Umgebungen im selben Ordner. versuche, den gesamten #DEV-Konfigurationsblock zu entfernen und nginx neu zu laden – Miro