Can't get phppgadmin to work with nginx
Hi, I'm trying to setup a local PHP development environment with Nginx, PostgreSQL and phpPgAdmin. This is my configuration file for Nginx:
user http;
worker_processes auto;
worker_cpu_affinity auto;
pcre_jit on;
events {
worker_connections 2048;
}
http {
error_log /var/log/nginx/error.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
aio threads;
types_hash_max_size 4096;
server_tokens off; # Security: Disables nginx version in error messages and in the “Server” response header field.
charset utf-8; # Force usage of UTF-8
include sites-enabled/*; # See Server blocks
server {
listen 80;
listen [::1]:80;
server_name localhost;
root /srv/http/dev;
location / {
index index.php index.html index.htm;
}
include php.conf;
}
}
I created a separate configuration for php-fpm, as suggested by the Archwiki, which looks like this:
location ~ \.php$ {
try_files $uri $document_root$fastcgi_script_name =404;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
# prevention for httpoxy vulnerability: https://httpoxy.org/
fastcgi_param HTTP_PROXY "";
}
and the file for phppgadmin under /etc/nginx/sites-available/ as follows:
server {
server_name phppgadmin.dev;
root /usr/share/webapps/phppgadmin;
index index.php;
include php.conf;
}
Typing http://localhost in the browser works as expected: I can run any PHP file with no problem. However, if I type phppgadmin.dev I get "This site can't be reached" from Chromium.
I added the phppgadmin.dev entry to the /etc/hosts file and I can ping it successfully from my terminal. What am I doing wrong?
About this post
- Posted
- Archived
- Score
- 13 · 100% up
- Kind
- Text
- ID
- aa0mt6
8 comments
The TLD .dev is managed by google and they added it to the hsts preload list. So your browser is automatically trying to connect to :443 (Which you don't have enabled in nginx?)
https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/
Thanks, I changed the server block to this
but still doesn't work, but in a different way. If I type
phppgadmin.localhostin the browser, nginx behaves as if I had typed justlocalhost.What are the other relevant server blocks, especially the one you think is being used? Nginx picks one in this order based on the hostname in the request:
Source: http://nginx.org/en/docs/http/server_names.html
I'm not sure about how the localhost name gets resolved, but is it possible to use subdomains to localhost? As far as I know, it shouldn't be and that's why you can't listen on a localhost subdomain. The solution would be to simply listen on the localhost (and use different ports if you need different services).
I keep reading that as "phpmageddon"…
OT: Why not pgadmin?
Because I feel phppgadmin is closer to phpmyadmin, which I'm already familiar with. Also pgadmin pulls down so many Python dependencies for a total installed size of ~200 MB. Phppgadmin is only a few megabytes.