-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Nginx needs to listen on public host (currently listens on backnet) - Add trailing / in nginx config so routes are proxied through - Add VIZ3D to index_fmt - Add all public ports that IndeX could be assigned to the list of allowed_origins
- Loading branch information
Showing
9 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
"""rsiviz (nginx + IndeX) | ||
:copyright: Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved. | ||
:copyright: Copyright (c) 2019-2023 RadiaSoft LLC. All Rights Reserved. | ||
:license: http://www.apache.org/licenses/LICENSE-2.0.html | ||
""" | ||
from pykern import pkconfig | ||
from pykern.pkcollections import PKDict | ||
from pykern.pkdebug import pkdp | ||
from rsconf import component | ||
from rsconf import db | ||
from rsconf import systemd | ||
|
||
|
||
class T(component.T): | ||
def internal_build_compile(self): | ||
self.buildt.require_component("nginx") | ||
jc, z = self.j2_ctx_init() | ||
self.__host = self.hdb.rsconf_db.host | ||
if "index_uri_secret" not in z: | ||
z.index_uri_secret = db.random_string() | ||
z.global_resources.index_uri_fmt = ( | ||
f"https://{self.__host}:{{}}/{z.index_uri_secret}/" | ||
z.global_resources.viz3d.index_uri_fmt = ( | ||
f"https://{z.index_vhost}:{{}}/{z.index_uri_secret}/" | ||
) | ||
z.global_resources.viz3d.index_allowed_origins = f" ".join( | ||
[ | ||
f"{z.index_vhost}:{p}" | ||
for p in range( | ||
jc.sirepo.global_resources.public_ports_min, | ||
jc.sirepo.global_resources.public_ports_max, | ||
) | ||
] | ||
) | ||
|
||
def internal_build_write(self): | ||
from rsconf.component import nginx | ||
|
||
nginx.install_vhost( | ||
self, | ||
vhost=self.__host, | ||
vhost=self.j2_ctx.rsiviz.index_vhost, | ||
j2_ctx=self.j2_ctx, | ||
) | ||
|
||
def sirepo_config(self, sirepo): | ||
sirepo.j2_ctx.rsiviz.global_resources.index_uri_fmt = ( | ||
self.j2_ctx.rsiviz.global_resources.index_uri_fmt | ||
sirepo.j2_ctx.rsiviz.global_resources.viz3d = ( | ||
self.j2_ctx.rsiviz.global_resources.viz3d | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/pkcli/build_data/1.out/srv/host/v9.radia.run/etc/nginx/conf.d/rsiviz.v9.radia.run.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
server { | ||
listen rsiviz.v9.radia.run:12000; | ||
server_name rsiviz.v9.radia.run; | ||
root /usr/share/nginx/html; | ||
ssl_certificate /etc/nginx/conf.d/rsiviz.v9.radia.run.crt; | ||
ssl_certificate_key /etc/nginx/conf.d/rsiviz.v9.radia.run.key; | ||
|
||
location /a_secret_uri/ { | ||
proxy_pass http://127.0.0.1:12000/; | ||
|
||
} | ||
|
||
} | ||
server { | ||
listen rsiviz.v9.radia.run:12001; | ||
server_name rsiviz.v9.radia.run; | ||
root /usr/share/nginx/html; | ||
ssl_certificate /etc/nginx/conf.d/rsiviz.v9.radia.run.crt; | ||
ssl_certificate_key /etc/nginx/conf.d/rsiviz.v9.radia.run.key; | ||
|
||
location /a_secret_uri/ { | ||
proxy_pass http://127.0.0.1:12001/; | ||
|
||
} | ||
|
||
} |
26 changes: 0 additions & 26 deletions
26
tests/pkcli/build_data/1.out/srv/host/v9.radia.run/etc/nginx/conf.d/v9.radia.run.conf
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters