Issue
Hi I am trying to configure jupyter lab to only allow access from certain IPs. I know that I can set
c.ServerApp.allow_origin = '*'
in the config file at ~/.jupyter/jupyter_lab_config.py
but I worry that this is to broad.
The docs mention the option ServerApp.allow_origin_pat
which accepts a regex to allow only matching origins. Unfortunately they dont mention what regex syntax they are using. If for example I want to restrict access to localhost
, 127.0.0.1
, 192.39.*
I would use the following regex with the python syntax: 192\.39\.\d+\.\d+|localhost|127\.0\.0\.1
. However when starting jupyter lab will complain as follows:
[E 2022-08-24 11:09:54.311 LabApp] Exception while loading config file /home/user/.jupyter/jupyter_lab_config.py
Traceback (most recent call last):
File "/home/user/miniconda3/envs/optuna_raytune/lib/python3.9/site-packages/traitlets/config/application.py", line 738,
in _load_config_files
config = loader.load_config()
File "/home/user/miniconda3/envs/optuna_raytune/lib/python3.9/site-packages/traitlets/config/loader.py", line 614, in l
oad_config
self._read_file_as_dict()
File "/home/user/miniconda3/envs/optuna_raytune/lib/python3.9/site-packages/traitlets/config/loader.py", line 646, in _
read_file_as_dict
exec(compile(f.read(), conf_filename, 'exec'), namespace, namespace)
File "/home/user/.jupyter/jupyter_lab_config.py", line 605
1xtra arguments that will be passed to Jinja environment.
^
SyntaxError: invalid syntax
So my question is, how do I construct a correct regex?
Solution
Your error is "1xtra" on line 605 in file "/home/user/.jupyter/jupyter_lab_config.py". You need to comment that line out (and optionally correct the miss-spelling). Also, be aware that all of the 127/8 block is localhost.
Answered By - Andrew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.