So, I have next problem. This is my nginx config
server {
disable_symlinks off;
listen 80;
server_name g9tv.loc;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root /home/dejmos/www/g9tv;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php;
}
error_page 404 /index.php;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/dejmos/www/g9tv;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
root /home/dejmos/www/g9tv;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/dejmos/www/g9tv$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
When I go to page that not exists on server I got 404 page provided by nginx, but I need to get 404 page provided by codeigniter show_404() function.
Problem resolved. It caused by subfolder. I place Codeigniter to root folder and all ok now.
Related
I have a problem during configure nginx in Amazon Linuz AMI, I installed nginx on Amazon Linuz AMI and pulled my cakephp project into /var/www/html. But the problem is that when I try to access to the index.php file into the webroot folder with nginx I have a 404 Not Found error.
Do you have any suggestion ?
Here is my Config nginx file:
server {
root /var/www/html/orangescrum;
server_name payzilla.in www.payzilla.in;
index index.html index.htm index.php;
access_log /var/log/nginx/app_access.log;
error_log /var/log/nginx/app_error.log;
try_files $uri $uri/ /index.html;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
rewrite ^/$ /app/webroot/ break; rewrite
^(.*)$ /app/webroot/$1 break;
}
location ~ \.(php|phar)(/.*)?$ {
fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;
fastcgi_intercept_errors on;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/mydomain/html$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass php-fpm;
}
location ~ /\.ht {
deny all;
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
Please provide the Best Configuration file for both http and https for Amazon Linux AMI
We also need to set up the SSL part also
My Laravel app is returning 404 on every route.
This is the address: http://67.205.191.11/, when I try for example http://67.205.191.11/classes, 404 not found is returned.
my nginx default config file looks as below:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/venture-backend/public/;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name 67.205.191.11;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#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 /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Anyone knows why my routes are not working?
I did the following configurations for nginx server for code igniter and worked correctly , unfortunately there is one case not working.
When I request URL with parameter Like
servername.com/ControllerName/methodName?param=value
I got Not found Page 404
Server Configurations :
server {
# access from localhost only
listen 127.0.0.1:80;
server_name serverName.com;
root API;
log_not_found off;
charset utf-8;
access_log logs/accessservername.log main;
index index.php;
# handle files in the root path /www
location / {
try_files $uri $uri/ /index.php?$args;
}
#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 API;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9100
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php;
fastcgi_index index.php;
#fastcgi_param PHP_FCGI_MAX_REQUESTS 1000;
#fastcgi_param PHP_FCGI_CHILDREN 100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
include fastcgi_params;
}
# add expire headers and speed up image access with a vary header
location ~* ^.+.(gif|ico|jpg|jpeg|png|flv|swf|pdf|mp3|mp4|xml|txt|js|css)$ {
expires 30d;
add_header Vary Accept-Encoding;
}
# only allow these request methods
if ($request_method !~ ^(GET|HEAD|POST)$ ){ return 405; }
}
I have my website stored in /usr/share/nginx/html .gave 777 to all directories and files.when i fire-up the browser and navigate to website, it downloads the page rather than displaying it.
php-fpm is installed and running
this my /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name hostedweb.net;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.htm;
}
#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 /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
I'm on CentOS 6
any help is appreciated
In your location ~ \.php$ { try adding include fastcgi_params;
Also in your php portion you could try taking out the root html; portion, or try setting it to root /usr/share/nginx/html;
Have you tried removing or commenting out fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;? I don't have that line in any of my nginx config files and they seem to work fine.
Did you try adding
try_files $uri $uri/;
To your location / {} block
And I believe you don't need this line
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
because you included the fastcgi_params
I setup a nginx server in my localhost
So now I want to enable clean url for this server
(Change localhost/drupalsite/?q=abc to localhost/drupalsite/abc)
I have tried some tutorials but thet don't work for me
http://wiki.nginx.org/Drupal
https://drupal.org/node/976392
http://richardbanks.net/blog/2012/11/nginx-url-rewrites-the-correct-method
This is some basic config in nginx.conf file
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /srv/nginx/www/nginx_htdocs/;
index index.html index.htm index.php;
}
#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 /srv/nginx/www/nginx_htdocs/;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $request_filename;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /srv/nginx/www/nginx_htdocs/$fastcgi_script_name;
include fastcgi_params;
}
#--------------- TUNG CUSTOM
#------------- END CUSTOM
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Here's a gist of a full configuration that works very well with Drupal's clean URL's
You must try to handle not found urls as possible query strings for index.php (if that's how Drupal works, which I'm not sure).
For example, in your first location block:
location / {
root /srv/nginx/www/nginx_htdocs/;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$request_uri;
}
This way, if
`http://mysite.com/xyz`
doesn't match any file or folder, it gets handed to index.php in the form of
`http://mysite.com/index.php?xyz`