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

Nginx container configuration for remote web_UI #50

Open
sofinan opened this issue Jan 25, 2023 · 2 comments
Open

Nginx container configuration for remote web_UI #50

sofinan opened this issue Jan 25, 2023 · 2 comments

Comments

@sofinan
Copy link

sofinan commented Jan 25, 2023

Hello
I was trying to install remote WEB_UI and all my attempts were unsuccessful.
I`ve added next part of code to nginx configuration to corresponding location for CORS:

                if ( $request_method !~ ^(GET|POST|HEAD|OPTIONS|PUT|PATCH|DELETE)$ ) {
                        return 444;
                }

                set $origin $http_origin;

                if ($origin !~ '^http?://(localhost\:8080|97\.53\.245\.19\:18256)$') {
                        set $origin 'http://localhost';
                }

                if ($request_method = 'OPTIONS') {
                        add_header 'Access-Control-Allow-Origin' "$origin" always;
                        add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS' always;
                        add_header 'Access-Control-Allow-Headers' 'Content-Type, Accept, Authorization' always;
                        #add_header 'Access-Control-Allow-Headers' '*' always;
                        add_header 'Access-Control-Allow-Credentials' 'true' always;

                        add_header Access-Control-Max-Age 1728000;
                        add_header Content-Type 'text/plain charset=UTF-8';
                        add_header Content-Length 0;
                        return 204;
                }

                if ($request_method ~ '(GET|POST|PATCH|PUT|DELETE)') {
                        add_header Access-Control-Allow-Origin "$origin" always;
                        add_header Access-Control-Allow-Methods 'GET, POST, PATCH, PUT, DELETE, OPTIONS' always;
                        add_header Access-Control-Allow-Headers 'Content-Type, Accept, Authorization' always;
                        add_header Access-Control-Allow-Credentials true always;
                }

But when I am trying to login I get error 500 ?
What is the reason of the behaviour?
Do you have an example of working nginx configuration to allow remote UI?
Thanks lot!

@sofinan
Copy link
Author

sofinan commented Jan 25, 2023

Error on Core side:
ERROR GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /login/ajaxSuccess Stacktrace follows: java.lang.NullPointerException at be.cytomine.security.LoginController.ajaxSuccess(LoginController.groovy:172) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:282) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:203) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:181) at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) at cytomine.web.APIAuthentificationFilters.doFilter(APIAuthentificationFilters.groovy:46) at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49) at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

@sofinan
Copy link
Author

sofinan commented Jan 26, 2023

So, currently weve noticed that if we send request from remote client the core dont receive JSESSIONID which related to the error from previous comment.
To avoid the problem we changed http -> https and added parameter sameSite=None in nginx.conf
But we faced with the problem - logout request doesn`t work.

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

1 participant