Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring base_url for sregistry when deployed behind an Apache reverse proxy on port 80 #441

Open
imerelli opened this issue Oct 7, 2023 · 3 comments

Comments

@imerelli
Copy link

imerelli commented Oct 7, 2023

Hello,

I'm trying to deploy sregistry behind an Apache reverse proxy on port 80 and have run into some issues with the application's URLs. I've set up Apache to route requests from /sregistry to the sregistry application running on port 81, as I have other sites and configurations on my server.

Here's my current Apache configuration:

<VirtualHost *:80>

    # Enable rewrite module
    RewriteEngine On

    # Redirect /sregistry to /sregistry/
    RewriteRule ^/sregistry$ /sregistry/ [R=301,L]

    # Proxy requests to sregistry
    RewriteRule ^/sregistry/(.*)$ http://localhost:81/$1 [P,L]

    ProxyPreserveHost On
    ProxyRequests Off

    # Handle reverse proxying
    ProxyPassReverse /sregistry/ http://localhost:81/

    # Specific rules for static resources
    ProxyPass /static/ http://localhost:81/static/
    ProxyPassReverse /static/ http://localhost:81/static/
</VirtualHost>

With this configuration, I'm able to access the sregistry homepage fine. However, some internal application links, like /collections and /login, are broken because they don't seem to be aware of the /sregistry prefix.

I assume there's a need to adjust a base_url or similar setting in the sregistry configuration to inform it of the /sregistry prefix. Could you provide guidance on how to properly configure this or point out if there's any step I might be overlooking?

Thank you for your assistance!

@vsoch
Copy link
Member

vsoch commented Oct 7, 2023

The setup is built with Nginx, so first I’d start with modifying that configuration first (instead of putting it behind a different webserver). Then if you want to tweak the baseurl it should be in settings.py, and you can build a custom image.

@imerelli
Copy link
Author

imerelli commented Oct 7, 2023

Hi vsoch, thank you for the suggestion. On the server I have apache, so I have to pass through it using a simple rewrite rule
(I didn't touched nginx). However, I changed these settings and more or less it works:

urlpatterns = [
url(r"^sregistry/admin/", admin.site.urls),
url(r"^sregistry/", include(base_urls)),
url(r"^sregistry/api/", include(api_urls)),
url(r"^sregistry/", include(library_urls)), # Sylabs library API - includes v1 and v2 (damn)
url(r"^sregistry/api/schema/$", schema_view),
url(r"^sregistry/api/docs/", include_docs_urls(title=API_TITLE, description=API_DESCRIPTION)),
url(r"^sregistry/", include(main_urls)),
url(r"^sregistry/", include(user_urls)),
url(r"^sregistry/sitemap.xml$", index, {"sitemaps": sitemaps}, name="sitemap"),
url(r"^sregistry/sitemap-(?P

.+).xml$", sitemap, {"sitemaps": sitemaps}),
url(r"^sregistry/django-rq/", include("django_rq.urls")),
]

But I don't see css and images. Any suggestion about this?

@vsoch
Copy link
Member

vsoch commented Oct 7, 2023

You likely want to look at your console logs to see the path that is being tried, and adjust accordingly. The roots are defined here:

sregistry/shub/settings.py

Lines 549 to 556 in 675fb4d

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
MEDIA_ROOT = "/var/www/images"
MEDIA_URL = "/images/"
STATIC_ROOT = "/var/www/static"
STATIC_URL = "/static/"
UPLOAD_PATH = "%s/_upload" % MEDIA_ROOT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants