I am running a NodeJS application in Nginx with a reverse proxy to port 3000
PhpMyAdmin is configured and apparently runs in /phpmyadmin
/etc/nginx/sites-available/default is configured like this:
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost mywebsite.com www.mywebsite.com;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /phpmyadmin {
root /var/www/html/phpmyadmin/;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
I managed to make all work as I wanted, but PhpMyAdmin has a bad display:
Before setting the reverse proxy in that file, PhpMyAdmin ran perfect. I assume there is something I missed in default file. Any ideas? Thanks
To Ivan Shatsky's Response: #IvanShatsky
I tried substituting with your code, but it downloads a file (it does not read .php files) - So, I added few more lines:
location ^~ /phpmyadmin {
index index.php;
try_files $uri $uri/ /phpmyadmin/index.php$is_args$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
The result is the same before.
When I check the resources of the network, this is what happens:
I have performed chmod 777 -R /var/www/html/phpmyadmin but no changes. Would I need to have https? - I am currently trying on http.
I wonder how it is running at all. Assuming your phpMyAdmin located in the /var/www/html/phpmyadmin directory, try this:
location /phpmyadmin {
index index.php;
try_files $uri $uri/ /phpmyadmin/index.php$is_args$args;
}
Related
I am using Drupal 8 with nginx . I have a multiProject Environment with single domain.
I have 10 Drupal sites. which works as
https://example.com/site1
https://example.com/site2
Each site has its on distinct docker container and everything is running smooth on production. But I noticed A issue with few sites. They give 404 without a trailing slash .Only 4 of them. Rest six automatically appends the slash when I remove them and hit in browser.
The nginx config for all are exactly same.
Here is the nginx config for a site :
server
{
client_max_body_size 128m;
root /var/www/html;
index index.php index.html index.htm;
location /site1 {
try_files $uri/ $uri /site1/index.php?$query_string;
}
error_page 404 /404.html;
error_page 403 /403.html;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri $uri/ /index.php?q=$uri&$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
add_header Access-Control-Allow-Origin *;
proxy_set_header Access-Control-Allow-Origin $http_origin;
}
}
I have tried every thing , rewrite, try files and returns.
can any one help.
I'd like to serve two applications from the same server through nginx. I'd like these applications to be available through a single domain name with sub-uris.
e.g.
www.example.com => should serve normal example site.
www.example.com/blog => blog.example.com (wordpress) site which is at different directory
Here, anything user requests from /blog/... should be served from blog site, but url should be www.example.com/blog/...
I have tried this.
server {
root /web/servers/example/public;
...
...
location /blog {
proxy_pass http://blog.example.com;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Other try was,
location /blog {
alias /web/servers/blog/public;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
# pass the PHP scripts to FastCGI server
location ~ \.php$ {
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
#allow 127.0.0.1;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_index index.php;
}
}
None of the options are working for /blog. Main site is working fine.
Could anybody please help me to solve the issue?
I have bought a domain with an accent mark inside: something like www.èxample.com.
My problem is that even if I configured my nginx server block (virtual host) in a correct way, it doesn't match the directory that I made.
I tried to use the same configuration with a domain without an accent mark and everything work fine.
This is my server block file inside site-availables folder:
server {
listen 80;
root /var/www/example.com;
index index.php index.html index.html;
server_name *.èxample.com;
client_max_body_size 4G;
charset utf-8;
access_log /var/www/example.com/logs/nginx-access.log;
error_log /var/www/example.com/logs/nginx-error.log;
location / {
try_files $uri $uri/ /index.html;
}
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =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;
}
}
How can I solve this problem?
Thanks!
I am new to symfony. I am trying to setup symfony2 on ubuntu server with nginx. but it shows 500 internal server error. I have this server running some laravel projects as well and its find
Anyone can help what the problem is?
my nginx configuration is :
server {
listen 80;
root /home/ubuntu/test-symfony/web;
index app.php;
# Make site accessible from http://localhost/
server_name symfony.jonesjapriady.com http://symfony.jonesjapriady.com;
error_log /var/log/nginx/symfony2.error.log;
access_log /var/log/nginx/symfony2.access.log;
location / {
try_files $uri /app.php?$query_string;
}
location ~ ^/(app_dev|app_test.php|app)\.php(/|$) {
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
}
}
I am running a VPS server with Centos and Plesk.
The server is working right, on a Nginx + php-fpm setup.
So, websites are served correctly, but when user tries to access to its webemail ( roundcube tool installed ), doesn't work.
My current nginx conf for webmail is :
server {
listen [my server ip...]:80;
server_name webmail.* roundcube.webmail.* horde.webmail.* atmail.webmail.*;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_read_timeout 90;
location / {
root /usr/share/psa-roundcube;
index index.php index.html index.htm;
location ~ \.php$
{
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_keep_conn on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
}
}
}
What can be wrong?
This snippet works for me on CentOS 6.5. The SCRIPT_FILENAME is different and the is fastcgi_index is present. Think that's it.
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
I have copied it from here and it works. The other directives in this particular example are very worth to get noticed/copied to harden the plesk setup just a little.