pgadmin4 icon indicating copy to clipboard operation
pgadmin4 copied to clipboard

404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Open iwebroot opened this issue 5 months ago • 0 comments

Please note that security bugs or issues should be reported to [email protected].

Describe the bug No error during installation but after go to the URL, I have this issue image

To Reproduce

  1. Install dependencies:
apt install htop virtualenv libpq-dev python3-dev gunicorn postgresql python3-flask python3-keyring python3-dateutil python3-flask-migrate python3-flask-babel python3-flask-sqlalchemy python3-flask-login python3-flask-security python3-flask-paranoid python3-flask-mail python3-flask-socketio python3.11-venv -y
  1. Create folder for pgadmin4
mkdir -p /var/lib/pgadmin4/sessions && mkdir /var/lib/pgadmin4/storage && mkdir /var/log/pgadmin4 && mkdir /opt/pgadmin4
  1. Create user
adduser --system --group --home /var/lib/pgadmin4 --disabled-login --shell /usr/sbin/nologin pgadmin 
  1. Init environment and active this
python3 -m venv /opt/pgadmin4/venv
source /opt/pgadmin4/venv/bin/activate
  1. Downgrade pip because the installation will failed
pip install --upgrade 'pip<24.1' wheel
  1. Install pgAdmin4, gunicorn, setuptools
python3 -m pip install pgadmin4 && python3 -m pip install gunicorn && python3 -m pip install setuptools
  1. Configure config_local.py
  • Location: /opt/pgadmin4/venv/lib/python3.11/site-packages/pgadmin4/config_local.py
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'
AZURE_CREDENTIAL_CACHE_DIR = ''
KERBEROS_CCACHE_DIR = ''
SERVER_MODE = True
  1. Setup DB and set mail and password administrator
python3 /opt/pgadmin4/venv/lib/python3.11/site-packages/pgadmin4/setup.py setup-db
  1. Set correct permission
chown -R pgadmin:pgadmin /var/log/pgadmin4 /var/lib/pgadmin4 /opt/pgadmin4
  1. Create systemd
nano /etc/systemd/system/pgadmin4.service

Paste ...

[Unit]
Description = pgAdmin4 Service
After = network.target network-online.target
Wants = network-online.target

[Service]
User=pgadmin
WorkingDirectory=/opt/pgadmin4/
ExecStart=/opt/pgadmin4/venv/bin/gunicorn \
	--bind unix:/tmp/pgadmin4.sock \
	--workers=1 \
	--threads=25 \
	--chdir /opt/pgadmin4/venv/lib/python3.11/site-packages/pgadmin4 \
	pgAdmin4:app
	
[Install]
WantedBy = multi-user.target
  1. Enable and start service and deactivate the environment
systemctl enable pgadmin4.service && systemctl start pgadmin4.service && deactivate
  1. Configure App Server from WebAdmin OpenLiteSpeed image

  2. Configure Context from WebAdmin OpenLiteSpeed image

  3. Restart OpenLiteSpeed

  4. Go to https://domain.tld/pgsql-manager/

Error message into log

2024-09-12 07:56:35,579: ERROR  pgadmin:        404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
Traceback (most recent call last):
  File "/opt/pgadmin4/venv/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pgadmin4/venv/lib/python3.11/site-packages/flask/app.py", line 854, in dispatch_request
    self.raise_routing_exception(req)
  File "/opt/pgadmin4/venv/lib/python3.11/site-packages/flask/app.py", line 463, in raise_routing_exception
    raise request.routing_exception  # type: ignore[misc]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pgadmin4/venv/lib/python3.11/site-packages/flask/ctx.py", line 362, in match_request
    result = self.url_adapter.match(return_rule=True)  # type: ignore
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pgadmin4/venv/lib/python3.11/site-packages/werkzeug/routing/map.py", line 629, in match
    raise NotFound() from None
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Screenshots image

Desktop (please complete the following information):

  • OS: Debian
  • Version: 12
  • Mode: Server
  • Browser (if running in server mode): chrome
  • Package type: Python

Additional context

  • Web server: OpenLiteSpeed
  • Version: 1.8.1

iwebroot avatar Sep 12 '24 08:09 iwebroot