@qudri

Как настроить nginx для css|img|js?

Приветствую
Конфиг:
events {
    worker_connections  784;
    use epoll;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    access_log  off;

    gzip  off;

    server {
        set $my_root "/var/www/html/public_html";
	    root $my_root;
        listen 0.0.0.0:80;
        server_name site.loc;
        if ($native = "") {
            set $native "ru";
        }
        rewrite ^/(.*)/$ /$1 permanent;

		charset utf-8;
		source_charset utf-8;

		error_log /var/log/site.ru.error_log error;
		include /etc/nginx/fastcgi_params;

		location /maintenance.html {
		    root $my_root/public_html;
		    allow all;
		}

		location ~* ^/(signup|login) {
		    if ($scheme = http) {
			    return 301 http://site.loc/$1/?$query_string;
		    }

		    try_files $uri $uri/ /index.php?q=$uri&$args;
		}

		location ~* /files/avatars/avatar_(\d+)_(\d+)\.jpg {
		    expires max;
		    access_log off;
		    log_not_found off;
		    try_files $uri /img/no-avatar/$2.png;
		}

		location ~* /files/blog/post_\d+/(small|medium|large)\.jpg {
		    expires max;
		    access_log off;
		    log_not_found off;
		    try_files $uri /img/blog/$1.jpg;
		}

		#location ~*  ^/(js|css|img|fonts)/([a-z0-9-\.\_]+)\.\d+\.(js|css|png|jpg|gif|woff)$ {
		#    add_header Vary Accept-Encoding;
		#    expires max;
		#    access_log off;
		#    log_not_found off;
		#    try_files /$1/$2.min.$3 /$1/$2.$3;
		#}
		location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
            expires max;
        }

		location ~* ^/(files|img|media|captcha|js|css|fonts) {
		    access_log off;
		    log_not_found off;
		    expires max;
		}

	    location ~* \.php$ {
	        fastcgi_pass web:9000;
            include        fastcgi_params;

	        fastcgi_param SCRIPT_FILENAME    	$my_root/$fastcgi_script_name;
	        fastcgi_param SCRIPT_NAME        	$fastcgi_script_name;
	        fastcgi_param APPLICATION_ENV    	development;
	        fastcgi_param X_NGINX_PAGE_CACHE	$scheme://$server_name$uri$is_args$args;
	        fastcgi_param X-Forwarded-For	    $proxy_add_x_forwarded_for;
	        fastcgi_index index.php;
	    }

	    location / {
	        index index.php;
            try_files $uri $uri/ /index.php$is_args$args;
        }

		location /xml.php {
		    add_header Access-Control-Allow-Origin *;
		    add_header Access-Control-Allow-Headers 'Origin, X-Requested-With, Content-Type, Accept';
		}

		location = /gag.html {
	        allow all;
	    }

		#location / {
		#    try_files $uri /index.php?q=$uri&$args;
	    #    rewrite ^(.*)$ /index.php break;
	    #    include fastcgi_params;
	    #    fastcgi_split_path_info ^(.+\.php)(/.+)$;
	    #    fastcgi_index index.php;
	    #    fastcgi_pass web:9000;
	    #    allow all;

	    #    fastcgi_param SCRIPT_FILENAME /var/www/html/public_html/$fastcgi_script_name;
	    #}
    }
}

Открывается главная страница, но ни один js|css|img файл не загружен, в консоли по ним 404я ошибка.
Так же ни по одной ссылке вглубь сайта провалиться не могу - тоже 404я.
Подскажите, в чём может быть проблема?
Используется древний zend 1.2, пытаюсь поднять сайт в docker'e.
  • Вопрос задан
  • 1117 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы