Problems with py4web on linux

37 views
Skip to first unread message

Davidiam

unread,
Aug 12, 2025, 11:41:14 AMAug 12
to py4web
We installed py4web on linux using nginx as a reverse proxy.
Py4web: 1.20250607.2 on Python 3.13.5  linux and nginx as reverse proxy

We have it configured using a url_prefix=project_name so our urls look something like this:


Note: We needed to remove the leading forward slashes '/' from the _default app index.html as otherwise it could not find the _dashboard and showcase apps using the buttons on the on the initial py4web screen and it couldn't find the logo.png .
After removing a few of the leading '/' characters that issue was resolved.

After we got it running, we wanted to add users in the auth user table of the _scaffolding app, but that was pretty much impossible.  
We tried adding it from the _dasboard apps database manager for _scaffold but it gave a message about an invalid hash.  

We then tried adding it by registering the user in the _scaffold app, but it was removing the port from the url when we click on the sign up button, which causes and app which is using the port 443 to throw an "xrsf" error.

I know from experience that there are sometimes easy solutions, so I am hoping that someone can give me an idea where to look.



Davidiam

unread,
Aug 13, 2025, 5:21:59 AMAug 13
to py4web
I realize that these issues are likely related to the nginx chich is not playing well with py4web, but maybe with this extra info it may help to clarify the cause:

To clarify, the error we get when trying to add a user in the scaffold app auth user table via the _dashboard interface is: 
Invalid field value: past_passwords_hash

but this is the first user we are adding in the table.  

Also when looking at why the port is disappearing from the url, I see the following in the _scaffold/auth/register (in developer mode in edge):
action="//myhost.example.com/myfirsteuda/_scaffold/auth/register"........

When it should be:
action="//myhost.example.com:8002/myfirsteuda/_scaffold/auth/register"........

Davidiam

unread,
Aug 14, 2025, 5:09:24 AMAug 14
to py4web
When I try to add a new user for the_scaffold app from the _dashboard, it generates this html where some links are correct and others aren't. 
In the html generated below, some links have one "myfirsteuda" too many, for example:

<div class="grid-wrapper"><div class="grid-header"><a class="grid-new-button infohref="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?mode=new&amp;referrer=68747470733A2F2F733273303065676B2E62652E7372762E6465762E7379732F6D796669727374657564612F5F64617368626F6172642F646261646D696E2F5F73636166666F6C642F64622F617574685F75736572"

Full html here.  Some urls are correctly generated.  Can someone tell me where I need to look to fix the badly generated urls, such as the one above? 

<!DOCTYPE html>
<html>
<head>
<base href="/myfirsteuda/_dashboard/static/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAAQEAAAEAIAAwAAAAFgAAACgAAAABAAAAAgAAAAEAIAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAPAAAAAA=="/>
<link rel="stylesheet" href="css/no.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />
<style>
.py4web-validation-error{margin-top:-16px; font-size:0.8em;color:red;}
.grid-table-wrapper{overflow-x: auto;}
body { background: black; color: white; }
body > center > * { max-width: 90vw; }
form { max-width: 900px; margin: 0 0 0 20px; }
nav.black a, a { color: #33BFFF; }
label:not(.help) { color: black; background-color: #d1d1d1; padding: 2px 5px; margin: 5px 0 0 10px; border-top-left-radius: 5px; border-top-right-radius: 5px}
span ~ label { border-radius: 5px}
label ~ div { position: relative; top: -4px}
button, a[role=button], input[type=submit], input[type=button] { background-color: #33BFFF; color: black}
p, input, textarea { margin: 5px}
thead>tr {background: black; border-top: 2px solid #33BFFF; border-bottom: 2px solid #33BFFF;}
tr:hover {background:#111111}
.grid-search-form {width:100%; max-width: 100%}
tbody tr:hover { background-color:#002233 }
.grid-search-form-tr {border-bottom: none}
.grid-td:last-child {text-align: right}
</style>
<!-- individual pages can customize header here -->
</head>
<body>
<header>
<!-- Navigation bar -->
<nav class="black">
<ul>
<li><a href="/myfirsteuda/_dashboard/index">Dashboard</a> / dbadmin</li>
</ul>
</nav>
</header>
<!-- beginning of HTML inserted by extending template -->
<center>
<div>
<!-- Flash alert messages, first optional one in data-alert -->
<flash-alerts class="padded" data-alert=""></flash-alerts>
</div>
<main class="padded">
<!-- contect injected by extending page -->
<h2>Table "auth_user"</h2>
<div class="grid-wrapper"><div class="grid-header"><a class="grid-new-button info" href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?mode=new&amp;referrer=68747470733A2F2F733273303065676B2E62652E7372762E6465762E7379732F6D796669727374657564612F5F64617368626F6172642F646261646D696E2F5F73636166666F6C642F64622F617574685F75736572" role="button"><i class="fas fa-plus"></i><span class="grid-new-button-text">&nbsp;New</span></a><div classes="grid-search" id="grid-search"><form class="grid-search-form"><table class="grid-search-form-table"><tr class="grid-search-form-tr"><td class="grid-search-form-td"><input class="grid-search-form-input" name="search_string" type="text"/></td><td class="grid-search-form-td"><input class="grid-search-button" type="submit" value="Search"/><input class="grid-clear-button" onclick="document.querySelector(&#x27;[name=search_string]&#x27;).value=&#x27;&#x27;;" type="submit" value="Clear"/></td></tr></table></form></div></div><div class="grid-table-wrapper"><table class="grid-table"><thead class=""><th class="grid-col-auth_user-id"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.id">Id</a></th><th class="grid-col-auth_user-username"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.username">Username</a></th><th class="grid-col-auth_user-email"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.email">Email</a></th><th class="grid-col-auth_user-first_name"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.first_name">First Name</a></th><th class="grid-col-auth_user-last_name"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.last_name">Last Name</a></th><th class="grid-col-auth_user-sso_id"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.sso_id">Sso Id</a></th><th class="grid-col-auth_user-action_token"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.action_token">Action Token</a></th><th class="grid-col-auth_user-last_password_change"><a href="/myfirsteuda/myfirsteuda/_dashboard/dbadmin/_scaffold/db/auth_user?orderby=auth_user.last_password_change">Last Password Change</a></th><th class="grid-col-column-8"></th></thead><tbody></tbody></table></div><div class="grid-footer"><div class="grid-info">No rows to display</div></div></div>


</main>
</center>
<!-- end of HTML inserted by extending template -->
<footer class="black padded">
<p>
Part of <a href="https://py4web.com">py4web</a>
</p>
</footer>
</body>
<!-- You've gotta have utils.js -->
<script src="js/utils.js"></script>
<!-- individual pages can add scripts here -->
</html>


Davidiam

unread,
Aug 14, 2025, 6:42:17 AMAug 14
to py4web
OK, I solved the problem of the double application name by adding a re-write in the nginx configuration to remove the double myfirsteuda in the urls
rewrite ^/myfirsteuda/myfirsteuda/(.*)$ /myfirsteuda/$1 break;
They are still displayed incorrectly when hovering over the buttons, but at least it is working.  I would still like to resolve the root cause of this issue to have a clean solution.

I have also managed to resolve the issue of the port number which was disappearing in the urls by adding extra config lines in my nginx config:
# Preserve port number
proxy_set_header Host $host:$server_port;  
proxy_set_header X-Forwarded-Port $server_port;  

Reply all
Reply to author
Forward
0 new messages