pgadmin-org / pgadmin4

pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
https://www.pgadmin.org
Other
2.49k stars 650 forks source link

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. #7914

Open iwebroot opened 1 month ago

iwebroot commented 1 month ago

Please note that security bugs or issues should be reported to security@pgadmin.org.

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
  2. Create folder for pgadmin4
    mkdir -p /var/lib/pgadmin4/sessions && mkdir /var/lib/pgadmin4/storage && mkdir /var/log/pgadmin4 && mkdir /opt/pgadmin4
  3. Create user
    adduser --system --group --home /var/lib/pgadmin4 --disabled-login --shell /usr/sbin/nologin pgadmin 
  4. Init environment and active this
    python3 -m venv /opt/pgadmin4/venv
    source /opt/pgadmin4/venv/bin/activate
  5. Downgrade pip because the installation will failed
    pip install --upgrade 'pip<24.1' wheel
  6. Install pgAdmin4, gunicorn, setuptools
    python3 -m pip install pgadmin4 && python3 -m pip install gunicorn && python3 -m pip install setuptools
  7. 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
  8. Setup DB and set mail and password administrator
    python3 /opt/pgadmin4/venv/lib/python3.11/site-packages/pgadmin4/setup.py setup-db
  9. Set correct permission
    chown -R pgadmin:pgadmin /var/log/pgadmin4 /var/lib/pgadmin4 /opt/pgadmin4
  10. 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

11. Enable and start service and deactivate the environment

systemctl enable pgadmin4.service && systemctl start pgadmin4.service && deactivate

12. Configure App Server from WebAdmin OpenLiteSpeed
![image](https://github.com/user-attachments/assets/7a4b1a6a-157e-4934-af5e-84c50f12f355)
13. Configure Context from WebAdmin OpenLiteSpeed
![image](https://github.com/user-attachments/assets/c604beb4-bef1-4dfb-a43d-0ed4c3c9b80c)

14. Restart OpenLiteSpeed
15. 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](https://github.com/user-attachments/assets/955bdc36-1ffc-403d-a9dc-6f130ecc23d7)

**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
pravesh-sharma commented 2 weeks ago

Hi @iwebroot,

You need to set the script name to /pgsql-manager in your web server configuration.