Keep getting blank page suitecrm - Nginx - Ubuntu 14.04 - nginx

this is my site .conf file:
server {
listen [::]:80;
listen 80;
root /usr/share/nginx/html/suitecrm/;
index index.php index.html index.htm;
access_log /var/log/nginx/suitecrmaccess.log;
error_log /var/log/nginx/suitecrmerror.log error;
# Block access to stuff in the root
location ~* \.(pl|cgi|py|sh|lua|log|md5)$ {
return 444;
}
# Block access to data folders
location ~ /(soap|cache|upload|xtemplate|data|examples|include|log4php|metadata|modules|diagnostic|blowfish|emailmandelivery)/.*\.(php|pl|py|jsp|asp|sh|cgi|tpl|log|md5)$ {
return 444;
}
location / {
try_files $uri $uri/ =404;
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
The paths are correct, I don't get what could be wrong here, any ideas please?

Have you looked at the suitecrm.log file to see what it says?

Related

Nginx removing parameters from request in main page

Good day,
Please tell me how to remove the parameters of the GET request from the main page of the site and so that the rest of the parameters are processed. That is, if there are any parameters on the main page when requested, make a redirect to the site without parameters.
server {
listen 80;
listen [::]:80;
root /var/www/public_html/public;
index index.php index.html index.htm;
server_name mysite.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}
}
Not tested but somethings on below lines should help you out
server {
listen 80;
listen [::]:80;
root /var/www/public_html/public;
index index.php index.html index.htm;
server_name mysite.com;
location / {
location = / {
if ($is_args)
rewrite / permanent;
try_files $uri $uri/ /index.php?$query_string;
}
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
#include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}
}

Server with multiple projects in /var/www?

I have a server that I want to use as a personal server, with all of my projects under /var/www.
I currently have two folders, /var/www/html and /var/www/site.
I want to be able to access these folders by the following URLs (123.123.123.123 is my server IP):
123.123.123.123/html and 123.123.123.123/site
Here is my default virtual host file:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name 123.123.123.123;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
And here is the one I created for /var/www/site, called site:
server {
listen 80;
listen [::]:80;
# Because this site uses Laravel, it needs to point to /public
root /var/www/site/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name 123.123.123.123;
location /site {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
But when I go to 123.123.123.123/site, it says 404 Not Found, so clearly I'm doing something wrong (and yes, I restarted nginx).
Please help!
You only need one server block, as both /html and /site live in the same server.
Use nginx -t to check that nginx really does restart without giving any errors.
As /site uses a complicated directory scheme, you will need to use a nested location block to get the paths correct.
Your first project seems to have a simple arrangement of static and PHP files. You can use a root /var/www; statement to map URIs beginning with /html to the html folder. See this document for more.
Something like this may work for you:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location ^~ /site {
alias /var/www/site/public;
if (!-e $request_filename) { rewrite ^ /site/index.php last; }
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
}
The default server does not need a server_name.

nginx - Rewrite url for php files

I recently moved a website which used Apache to Nginx.
How can I get an url which looks like this:
http://example.com/login
to point to http://example.com/login.php while keeping the .php out of the url?
My current configuration:
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html/;
index index.php index.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
I usually use something like this and it's SEO proof. Tested by a lot of my client sites, works like a charm.
In your /etc/nginx/conf.d/domain.tld.conf file include this :
server {
index index.html index.php;
location / {
if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; }
try_files $uri $uri/ $uri.html $uri.php?$args;
}
location ~ \.php$ {
if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; }
try_files $uri =404;
# add fastcgi_pass line here, depending if you use socket or port
}
}
Source i used a while a go

nginx - how to use 'try_files' and an 'index' statement in the same directory?

Both landing.php and all the other pages of my site are in the same directory. I want to be able to access both, however if I have a try_files statement as well as an index statement, I get a 404 error when accessing the index page.
Is there a way to achieve this without conflicting either?
Here's my configuration file:
server {
listen 80;
access_log /var/www/mysite.com/logs/access.log;
error_log /var/www/mysite.com/logs/error.log;
root /var/www/mysite.com/public_html/mysite/public/_main;
server_name www.mysite.com mysite.com;
location / {
index landing.php;
try_files $uri $uri.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
fastcgi_index landing.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
I finally worked out how to do this. What you need is two location blocks, like this:
location = / {
index landing.php;
}
location / {
try_files $uri $uri.php?$query_string;
}
What this does is use try_files for any other page such as www.site.com/somepage; however if the URL is www.site.com, it will fetch the index page.
Try the following config it worked for me:
server {
root /path/to/root;
index index.html index.htm;
server_name subdomain.domain.com;
location / {
try_files $uri $uri/ /index.html;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
}
}

Variable username inside url address in NGINX

I still struggling with making mystaticusername variable user name. I mean when I have particular username /statisusername/ backend working properly on nginx. But how can I make my configuration for more users? Means use instead mystaticusername some redirection where each username will know login to backend.
How can I change my nginx configuration?
server {
server_name example.com www.example.com;
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/www;
charset utf-8;
index index.html index.php /index.php;
location = / {
rewrite ^ /index.php;
}
location / {
rewrite ^([^\.]*)$ /$1.php;
rewrite ^/([A-Za-z0-9_]+)$ /admin/index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location /mystaticusername {
try_files $uri/ /admin/index.php?q=$uri&$args;
}
location = /mystaticusername/options {
try_files $uri $uri/ /admin/index.php?hotelname=$1&do=options;
}
}
Not much context given, so I'm just guessin... but looks like you could condense your location directives to 3 statements.
This will default to index.php, but in the case of example.com/mystaticusername if would try that url and since it does not exist (guessing) it would serve up /admin/index.php?q=$uri&$args. This would also allow urls like exmaple.com/about to resolve. Just make certain to not allow users to create a username of 'about'
location / {
try_files $uri $uri/ /admin/index.php?q=$uri&$args;
}
Not certain what your goal is, but this would get you example.com/mystaticusername/options to try serve up /admin/index.php?hotelname=$1&do=options
location ~* ^/[a-zA-Z0-9]*/options$ {
try_files $uri /admin/index.php?hotelname=$1&do=options;
}
Leave php as-is
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}

Resources