nignx not working try_files css js (laravel) - laravel

NGINX LOG
Chrome Network
I set nginx.
Routing has no problem.
css and js do not load.
It seems that only indexes are recognized in public folders.
I do not know what I missed or what the typo was.
server {
listen 80;
server_name laravel.test;
root /var/www/laravel/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(?:ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|swf)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
index index.html index.htm index.php;
charset utf-8;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 16 16k;
fastcgi_connect_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
}
location ~ /\.ht {
deny all;
}
access_log /var/log/nginx/laravel-access.log;
error_log /var/log/nginx/laravel-error.log error;
}
local php -S localhost:5000 It works well.
It does not seem to be a problem with the php code
++ ps
http://laravel.test 200
http://laravel.test/home 200
http://laravel.test/css/test.php 200
http://laravel.test/css/app.css 404
http://laravel.test/js/test.php 200
http://laravel.test/js/app.js 404

Related

Why Laravel9 + vue3 app production build keeps adding /build/ path in my URL?

This is my nginx config:
server {
listen 80;
listen [::]:80;
server_name test.com;
root /var/www/test.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
#include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
#fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
eveything is working except my url keeps displaying like this:
http://test.com/build` instead of `http://test.com/
http://test.com/build/profile/2` instead of `http://test.com/profile/2
is there a problem in my configuration?
and the worst part is when I try to refresh browser the page it returns 404.
Thank you!

The input file is not specified in nginx on manjaro linux

I use manjaro. I'm trying to deploy my site locally on the laravel framework. I use nginx server. When I go to the site page, I get the error: No input file specified. I think there is an error in the configuration files, but I don't know how to find it and fix it. Below are my configuration files
Nginx config file:
user mrgoodcat;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
#include /etc/nginx/sites-enabled/*;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
types_hash_max_size 4096;
server {
listen 80;
server_name localhost;
root /home/mrgoodcat/PhpstormProjects;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/mrgoodcat/PhpstormProjects;
index index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /usr/share/nginx/html;
include fastcgi.conf;
}
location = /favicon.ico {
access_log off;
log_not_found off;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/mrgoodcat/PhpstormProjects;
}
}
## #note Load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
}
Site config file:
server {
listen 80;
listen [::]:80;
server_name project-a;
root /home/mrgoodcat/PhpstormProjects/project-a/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}

Nginx 404 Not Found Error. How can I fix it?

I'm using Laravel 8 for my project.
Php: 7.4
Using AWS Nginx Server
My Application's Homepage is fine. The homepage is working well. But, when I'm clicking a link then I'm getting a 404 Not Found error from Nginx.
Here is my server config in nginx.conf
server {
listen 80;
listen [::]:80;
server_name something.com;
root /srv/something.com;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
What to do? What to change?
How to fix this error?

Public folder is forbidden in nginx

I successfully deploy my Laravel app to in digital ocean, but my CSS & JS file are 403 (Forbidden), inside my console it show me error of net::ERR_ABORTED 403 (Forbidden)
how can I give permission to my CSS &JS in my nginx on digital ocean?, any help
nginx config
// nginx configuration
server {
listen 80;
server_name DOMAIN_NAME_OR_IP_ADDRESS;
root /var/www/name_of_repo/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* {
deny all;
}
}

How to configure Orchid control panel, and nginx if needed, so that Orchid loads the javascript and css files?

How to configure Orchid control panel, and nginx if needed, so that Orchid loads the javascript and css files?
Under ubuntu 18.04 running vesta control panel, Orchid does not load the javascript and css content at somesite.com/dashboard.
Since nginx properly loads the css and javascript at the somesite.com/ it appears that the nginx conf is not causing it.
Any help would be greatly appreciated.
/home/user/conf/web/somesite.com.nginx.conf:
server {
listen some-server-ip:443 ssl;
server_name somedomain.com www.somedomain.com;
root /home/user/web/somedomain.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php index.html index.htm;
access_log /var/log/nginx/domains/somedomain.com.log combined;
access_log /var/log/nginx/domains/somedomain.com.bytes bytes;
error_log /var/log/nginx/domains/somedomain.com.error.log error;
ssl_certificate /home/user/conf/web/ssl.somedomain.com.pem;
ssl_certificate_key /home/user/conf/web/ssl.somedomain.com.key;
location / {
# added the following line to allow nginx to recognize laravel dynamically created directories
try_files $uri $uri/ /index.php?$query_string;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias /home/user/web/somedomain.com/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/user/web/somedomain.com/stats/;
include /home/user/conf/web/somedomain.com.auth*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/user/conf/web/snginx.somedomain.com.conf*;
}
Orchid relies entirely on Laravel settings
server {
listen 80;
server_name example.com;
root /example.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Pay attention to the documentation.
Solution: orchid.software/en/docs/installation > Publishing resources: php artisan orchid:link.

Resources