Tryton root in suddirectory

202 views
Skip to first unread message

PMan

unread,
Oct 31, 2017, 10:49:03 AM10/31/17
to tryton
Greetings all.
I have tryton starting with uwsgi. The root of the tryton instance is mysite.com/tryton
When I browse to that url, it redirects to mysite.com/index.html and then I get an error that says "index.html does not exist".
Is there a way to configure tryton/sao to be located at mysite.com/tryton (a subdirectory) instead of mysite.come/ (domain root) ?

I am using uwsgi behind apache.

Apache config is a single directive (using mod_uwsgi)
"proxypass /tryton uwsgi://127.0.0.1:8000"

Trytond.conf is:
# /etc/tryton/trytond.conf - Configuration file for Tryton Server
# (trytond, trytond-admin, trytond-cron)

[web]
# Settings for the web interface

# The IP/host and port number of the interface
listen = localhost:8000

# The hostname for this interface
#hostname =

# The root path to retrieve data for GET requests
root = /opt/Tryton/sao-4.4.4


[database]
# Database related settings

# The URI to connect to the SQL database (following RFC-3986)
uri = PostgreSQL://username:'password'@localhost:5432

# The path to the directory where the Tryton Server stores files.
# The server must have write permissions to this directory.
# (Internal default: /var/lib/trytond)
path = /opt/Tryton/var/lib/files

[session]
# Session settings

# The time (in seconds) until an inactive session expires
timeout = 300

Cédric Krier

unread,
Oct 31, 2017, 12:40:07 PM10/31/17
to tryton
On 2017-10-31 07:35, PMan wrote:
> The root of the tryton instance is mysite.com/tryton
> When I browse to that url, it redirects to mysite.com/index.html and
> then I get an error that says "index.html does not exist".
> Is there a way to configure tryton/sao to be located at
> mysite.com/tryton (a subdirectory) instead of mysite.come/ (domain
> root) ?

Not yet. If you want to have such setup, I think you should be able by
using a reverse proxy which will convert the path for trytond.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

PMan

unread,
Nov 3, 2017, 4:55:09 AM11/3/17
to tryton
I simplify the setup, just Werkzeug and mod_proxy. I still get redirects... here is my apache configuration:

<Location /tryton>
Options FollowSymLinks Indexes
SetHandler wsgi-handler
ProxyPass http://127.0.0.1:8000/
ProxyPassReverse http://127.0.0.1:8000/
</Location>

I tried it with and without the trailing slash after the port number, and got the same redirect.

Running trytond with the --dev flag, here is the output to the command line as it starts, and then redirects a request for mysite.com/tryton to mysite .com/index.html:

Tryton) root@host [/opt/Tryton]# ./bin/trytond --logconf /opt/Tryton/etc/logs.conf --dev -c /opt/Tryton/etc/trytond.conf
Thu Nov 02 20:41:06 2017] INFO:server:using /opt/Tryton/etc/logs.conf as logging configuration file
Thu Nov 02 20:41:07 2017] WARNING:py.warnings:/opt/Tryton/lib/python3.6/site-packages/trytond/modules/__init__.py:143: DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead.
module_config.readfp(fp)

Thu Nov 02 20:41:07 2017] INFO:trytond.modules:ir:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:res:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:currency:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:country:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:tests:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:party:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:company:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:account:registering classes
Thu Nov 02 20:41:07 2017] INFO:werkzeug: * Running on http://localhost:8000/ (Press CTRL+C to quit)
Thu Nov 02 20:41:07 2017] INFO:werkzeug: * Restarting with stat
Thu Nov 02 20:41:07 2017] INFO:server:using /opt/Tryton/etc/logs.conf as logging configuration file
Thu Nov 02 20:41:07 2017] WARNING:py.warnings:/opt/Tryton/lib/python3.6/site-packages/trytond/modules/__init__.py:143: DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead.
module_config.readfp(fp)

Thu Nov 02 20:41:07 2017] INFO:trytond.modules:ir:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:res:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:tests:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:country:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:currency:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:party:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:company:registering classes
Thu Nov 02 20:41:07 2017] INFO:trytond.modules:account:registering classes
Thu Nov 02 20:41:18 2017] INFO:werkzeug:127.0.0.1 - - [02/Nov/2017 20:41:18] "GET / HTTP/1.1" 302 -

Regards,
Paul

Dominique Chabord

unread,
Nov 3, 2017, 5:53:49 AM11/3/17
to tryton
2017-11-03 4:50 GMT+01:00 PMan <max...@gmail.com>:
> I simplify the setup, just Werkzeug and mod_proxy. I still get redirects... here is my apache configuration:
>
> <Location /tryton>
> Options FollowSymLinks Indexes
> SetHandler wsgi-handler
> ProxyPass http://127.0.0.1:8000/
> ProxyPassReverse http://127.0.0.1:8000/
> </Location>
>
> I tried it with and without the trailing slash after the port number, and got the same redirect.
>
your Proxy directives are not valid.

Cédric Krier

unread,
Nov 3, 2017, 6:40:07 AM11/3/17
to tryton
On 2017-11-02 20:50, PMan wrote:
> Running trytond with the --dev flag, here is the output to the command line as it starts, and then redirects a request for mysite.com/tryton to mysite .com/index.html:

Currently trytond redirect '/' to '/index.hml', it may be a problem for
your setup. See https://bugs.tryton.org/issue6677

PMan

unread,
Nov 3, 2017, 7:05:07 PM11/3/17
to tryton
To simplify further, I proxied to "/".

Apache config:

<Location />
Options +ExecCGI
SetHandler wsgi-handler
</location>
ProxyPass / http://localhost:8000/

I get this error in the browser:

Method Not Allowed
The method is not allowed for the requested URL.

I get this in the command line:

Fri Nov 03 21:34:17 2017] INFO:werkzeug:127.0.0.1 - - [03/Nov/2017 21:34:17] "GET /index.html HTTP/1.1" 405 -

Commenting out the <location> directives does not make a difference.
I don't know what to do...

PMan

unread,
Nov 4, 2017, 8:10:08 AM11/4/17
to tryton
Small edit:
In the command line, I get this:

Fri Nov 03 21:34:17 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 11:55:42] "GET / HTTP/1.1" 302 -
Fri Nov 03 21:34:17 2017] INFO:werkzeug:127.0.0.1 - - [03/Nov/2017 21:34:17] "GET /index.html HTTP/1.1" 405 -

Regards,
Paul

Cédric Krier

unread,
Nov 4, 2017, 8:40:07 AM11/4/17
to tryton
On 2017-11-04 05:04, PMan wrote:
> Fri Nov 03 21:34:17 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 11:55:42] "GET / HTTP/1.1" 302 -
> Fri Nov 03 21:34:17 2017] INFO:werkzeug:127.0.0.1 - - [03/Nov/2017 21:34:17] "GET /index.html HTTP/1.1" 405 -

It seems the index.html of sao is not accessible to trytond.

PMan

unread,
Nov 4, 2017, 12:00:06 PM11/4/17
to tryton
I'm getting closer...

Still proxied to "/" with the correct [web] root, I now get lots of missing bower_components.

Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/c3/c3.min.js HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /images/tryton-icon.png HTTP/1.1" 200 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/papaparse/papaparse.min.js HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/fullcalendar/dist/fullcalendar.min.js HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/bootstrap/dist/css/bootstrap.min.css HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/fullcalendar/dist/locale-all.js HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/bootstrap/dist/css/bootstrap.min.css HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/c3/c3.min.css HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /bower_components/fullcalendar/dist/fullcalendar.min.css HTTP/1.1" 404 -
Sat Nov 04 14:29:50 2017] INFO:werkzeug:127.0.0.1 - - [04/Nov/2017 14:29:50] "GET /dist/tryton-sao.min.css HTTP/1.1" 404 -

I upgraded sao to 4.6 (Trytond upgraded itself when I installed modules with pip3). There is no "bower_components" directory in sao. There is a "node_modules/bower" directory in sao.

I had to do grunt --force when installing sao. The npm install warnings:

(Tryton) root@host [/opt/Tryton/sao]# npm install --production
npm WARN deprecated bo...@1.8.2: ...psst! Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
npm WARN deprecated mini...@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated mini...@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated grace...@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated mini...@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN prefer global jsh...@2.8.0 should be installed with -g
npm WARN lifecycle tryto...@4.6.0~postinstall: cannot run in wd %s %s (wd=%s) tryto...@4.6.0 bower install /opt/Tryton/sao

Cédric Krier

unread,
Nov 4, 2017, 12:45:05 PM11/4/17
to tryton
On 2017-11-04 08:42, PMan wrote:
> npm WARN lifecycle tryto...@4.6.0~postinstall: cannot run in wd %s %s (wd=%s) tryto...@4.6.0 bower install /opt/Tryton/sao

So you have to run manually: 'bower install'

PMan

unread,
Nov 8, 2017, 7:55:07 PM11/8/17
to tryton
My mistake, I was attempting to install sao as root. There are many docs that say not to. So I ran npm install --production as a non-root user, and sao installed without errors.

@Cedric; I installed the patch you suggested, and now I do not get redirected back to /index.html. But /tryton is still not working. When configure apache like this:

ProxyPass /tryton http://127.0.0.1:8000
ProxyPassReverse /tryton http://127.0.0.1:8000

I can access mysite.com/tryton and there are no errors, but there is no javascript and no css. I cannot log in. There is no select db field.

When configure apache like this:

ProxyPass / http://127.0.0.1:8000

I can access mysite.com/ and I get the Tryton javascript forms to log in. I select the db, log in, and navigate around Tryton. It is GREAT! So with the patch applied, Tryton works great when it's root is "/".

It seems the patch prevents a redirect to /index.html, but does not serve the static files when Tryton/SAO web root is a subdirectory.

I am happy to try any new or different patches to make this work. I can be your laboratory :)

Many thanks!
Paul

Many thanks,
Paul

PMan

unread,
Nov 12, 2017, 6:00:08 AM11/12/17
to tryton
I am serving the static files from the web root with the following Apache config:

Alias "/bower_components" "/opt/Tryton/sao/bower_components"
Alias "/offcanvas.css" "/opt/Tryton/sao/offcanvas.css"
Alias "/dist" "/opt/Tryton/sao/dist"
Alias "/images" "/opt/Tryton/sao/images"
Alias "/node_modules" "/opt/Tryton/sao/node_modules"
Alias "/src" "/opt/Tryton/sao/src"
Alias "/locale" "/opt/Tryton/sao/locale"

mysite.com/tryton will render a nicely formatted login page, but there is no widget to select the database, so I cannot login. The database label is present, but no select widget... There are no errors in the apache log, and the Firefox debug tool only shows 1 error:

mysite.com/locale/en_US.json [HTTP/1.1 404 Not Found 68ms]

I don't see a en_US.json file in the local folder, so I don't understand how Tryton was working when the web root was "/". With the appropriate apache configuration (ProxyPass / 127.0.0.1:8000), mysite.com/ worked, I could log in and navigate around Tryton.

Maybe the missing us locale is not the reason there is no db selection widget.

Thanks in advance.
Paul

Cédric Krier

unread,
Nov 12, 2017, 6:15:07 AM11/12/17
to tryton
I guess subdirectory is not supported.

PMan

unread,
Nov 14, 2017, 9:30:06 AM11/14/17
to tryton
Thanks for the feed back, Cedric.
I moved it to a subdomain, and it is working.
I'll mark this closed. Thanks again!
Reply all
Reply to author
Forward
0 new messages