Symfony 3 assets no update - caching

I've init new projet in Symfony 3 with nginx and docker. It worked nice but my assets doesn't update in web/assets/bundle.js. Is i check my bundle.js after update, i see the old version.
I've remove the Symfony cache and my browser, but no result :
php bin/console assets:install
My nginx config :
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
error_log off;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
open_file_cache max=100;
}
And Symfony :
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name 127.0.0.1 0.0.0.0 myApp.local;
root /var/www/lfdw/web;
location ~ ^(.*)/(app|app_dev|app_test|config)\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
error_log /var/log/nginx/symfony_error.log;
access_log /var/log/nginx/symfony_access.log;
}
Do you have any idea ?
Thank you !

I had this problem on a local install the new assets wouldn't install at all.what i did was deleting the whole bundles directory in web and regenerated the assets.
Another hacky way would be to delete your vendors and composer install
If you are in prod you probably just need to execute this command:
app/console assetic:dump --env=prod --no-debug
http://symfony.com/doc/current/deployment.html#e-dump-your-assetic-assets

Related

can't download file laravel use nginx (Failed - Network error)

The problem has been solved !
i check error.log in nginx
2019/04/16 17:29:39 [crit] 12060#12060: *261 open() "/var/lib/nginx/fastcgi/6/05/0000000056" failed (13: Permission denied) while reading upstream, client: 118.70.67.64, server: govangtam.org, request: "GET /download HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "govangtam.org"
i'm change chown var/lib/nginx/fastcgi with user run PHP-FPM
sudo chown -R forge:forge /var/lib/nginx/fastcgi
------------------Question--------------------
I can't download file in storage laravel 5.7, nginx, php7.2
I have not found the cause yet, I use code on another server that is still working normally.
when downloading error Failed - Network error or Failed - File incomplete. i use nginx version nginx/1.14.2, Ubuntu 16.04
url: http://govangtam.org/download
router web.php
Route::get('download', function () {
$file = storage_path('app').'/abc.mp3';
return response()->download($file);
});
nginx domain.conf
server {
listen 80;
listen [::]:80;
root /home/forge/govangtam.org/public;
index index.php index.html index.htm;
server_name govangtam.org www.govangtam.org;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
proxy_cache_revalidate on;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
nginx.conf
user forge;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
# Basic Settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
client_max_body_size 20M;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# SSL Settings
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
# Logging Settings
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Gzip Settings
gzip on;
gzip_disable "msie6";
# Virtual Host Configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
proxy_read_timeout 950s;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
}

Docker Nginx weird behaviors

I am writing an nginx container to host a laravel site. Currently I am working on the nginx container and experiencing a weird behavior. Ever other other request you get can not connect and the other times you get the welcome page.
Here is my multi stage build
#
# PHP Dependencies
#
FROM composer:1.7 as vendor
COPY database/ database/
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--prefer-dist
#
# Frontend
#
FROM node:8.11 as frontend
RUN mkdir -p /app/public
COPY package.json webpack.mix.js /app/
COPY resources/ /app/resources/
WORKDIR /app
RUN npm install && npm run production
#
# Application
#
FROM nginx:latest
# Set upstream conf and remove the default conf
# RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf \
# && rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/
COPY . /var/www/studyup
COPY --from=vendor /app/vendor/ /var/www/vendor/
COPY --from=frontend /app/public/js/ /var/www/public/js/
COPY --from=frontend /app/public/css/ /var/www/public/css/
COPY --from=frontend /app/mix-manifest.json /var/www/mix-manifest.json
EXPOSE 80 443
THe nginx config file
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
client_max_body_size 20M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
error_log /dev/stderr;
gzip on;
gzip_disable "msie6";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-available/*.conf;
open_file_cache off; # Disabled for issue 619
charset UTF-8;
}
The sites available config
server {
listen 80;
listen [::]:80;
# For https
# listen 443 ssl;
# listen [::]:443 ssl ipv6only=on;
# ssl_certificate /etc/nginx/ssl/default.crt;
# ssl_certificate_key /etc/nginx/ssl/default.key;
server_name testsite.com;
root /var/www/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
error_log /var/log/nginx/laravel_error.log;
access_log /var/log/nginx/laravel_access.log;
}
I am not sure what is going on> I tried using the nginx latest and I could not even get the welcome page to go away. I personally have not been able to find anything about what is going on, but I might now what to search also. Any help would be great

Nginx 404 error on every page with magento (except front page)

i am breaking my head over this.
I have magento 1.8.1 and migrating this to a nginx server (from apache)
The main page does work, but when i try to go to a other page (like a category or product page) i get a 404 error from Nginx.
I can't get this solved.
I have php-fpm installed and running.
nginx version: nginx/1.1.19
and
PHP 5.3.10-1ubuntu3.12 (fpm-fcgi) (built: Jun 20 2014 00:40:17)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd.
My nginx.conf:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
##
# Basic Settings
##
server_tokens off;
sendfile on;
keepalive_timeout 5;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
map $scheme $fastcgi_https { ## Detect when HTTPS is used
default off;
https on;
}
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log notice;
rewrite_log on;
log_format main ?$remote_addr - $remote_user [$time_local] $request ?
??$status? $body_bytes_sent ?$http_referer? ?
??$http_user_agent? ?$http_x_forwarded_for??;
##
# Gzip Settings
##
gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
My site.conf:
server {
listen 80 default_server;
server_name xxx.stratoserver.net www.xxx.stratoserver.net; # like ServerName in Apache
root /var/www/vhosts/path_to; # document root
autoindex off; # we don’t want users to see files in directories
#ensure sensitive files are not accessible
location ~ (^/(app/\|includes/\|lib/\|/pkginfo/\|var/\|report/config.xml)\|/\.svn/\|/\.git/\|/.hta.+) {
deny all; }
location / {
index index.php index.html index.htm;
try_files $uri $uri/ #handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
if ($request_filename ~* ^.*?/([^/]*?)$)
{
set $filename $1;
}
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
add_header Access-Control-Allow-Origin *;
}
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
location ~* .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
}
Who can help me to get the rest of the website running.
The phpinfo.php file does work.
I had also same problem.
use link like this : magento181/index.php/prodct
instade of : magento181/product
This is url rewriting problem..

Joomla with Nginx Rewrite SEF url

I am using Ubuntu 12.04 with NGINX and PHP5-FPM. I've just migrated my Joomla website from Apache to NGINX. But i think rewrite rules are not working well.
All of the SEF links rewrite to the homepage, but in the url bar link seems right.
Example if i click example.com/a/b.html it looks like go to the link in the url bar but homapage is loading.
Thanks for your help.
/etc/nginx/sites-available/example.com file
server {
listen 80;
server_name example.com;
#server_name_in_redirect off;
#access_log /var/log/nginx/localhost.access_log main;
#error_log /var/log/nginx/localhost.error_log info;
root /var/www/example.com/public_html/;
index index.php index.html index.htm default.html default.htm;
# Support Clean (aka Search Engine Friendly) URLs
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ \.php$ {
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# caching of files
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
}
nginx.conf
user www-data;
worker_processes 8;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
# gzip_proxied any;
gzip_comp_level 6;
# gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
## Block spammers and other unwanted visitors ##
include /etc/nginx/blockips.conf;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Yes - this reply is over 3 years old, but, unfortunately, the same problem exists on the latest version of Joomla when using NGINX...
We had the exact same problem on one of our client's sites. The problem turned out to be related to one of PHP's $_SERVER constants not being set by the NGINX server - and that constant (which is `$_SERVER['PHP_SELF']) is used in many places in Joomla to return the current URL. We have described, in details, the problem and how to fix it, here.
if you're using subfolder / virtual hosts, try changing:
# Support Clean (aka Search Engine Friendly) URLs
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
To
# Support Clean (aka Search Engine Friendly) URLs
location /subfolder/ {
try_files $uri $uri/ /subfolder/index.php?q=$request_uri;
}
Hello this is my host configuration, wich is working fine with with Joomla 3.6.5 friendly URLs, Ubuntu 16.04 , PHP7 and nginx:
server {
listen 80;
server_name mydomain.com;
root /var/www/html/mydomain;
index index.php index.html index.htm default.html default.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
My solution was to make sure that this part of the php.ini is enabled: cgi.fix_pathinfo = 1. This fixed the problem that $_SERVER['PHP_SELF'] was not set.
I had it disabled by accident.
cgi.fix_pathinfo provides real PATH_INFO/PATH_TRANSLATED support for CGI. PHP's previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting of zero causes PHP to behave as before. Default is 1. You should fix your scripts to use SCRIPT_FILENAME rather than PATH_TRANSLATED. http://php.net/cgi.fix-pathinfo

CodeIgniter not setting csrf cookie with Nginx

I'm using nginx and I can't login to the admin panel. It's using https so that may be a part of it.
Here are the relevant portions of my nginx.conf
server {
listen 80;
listen 443 ssl;
ssl_certificate /ssl.crt;
ssl_certificate_key /ssl.key;
server_name mysite.com;
root /var/www/mysite;
index index.php;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
client_max_body_size 200M;
...
location ~ \.php {
fastcgi_pass 127.0.0.1:6000;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_param PYRO_ENV production;
include fastcgi_params;
}
Turns out I had to use www.mysite.com for server_name instead of just mysite.com.

Resources