Hello everyone,
I’m a data analyst and develop web applications for my company on its network by using R programming language and R Shiny. I have an ubuntu machine and I deployed my apps on ShinyProxy (https://www.shinyproxy.io/) which helps to deploy your R shiny web applications.
I needed authentication for accessing different apps with different groups. That’s why, I chose keycloak, so I can access to my apps as an authenticated user with keycloak.
Secondly, in order to secure the app, IT department gave me a ssl certificate and domain. I secured my app with nginx but I couldn’t secure keycloak login page of the app. My app is running on 8080 port and keycloak is running on 8081 port.
In the following chunk, you can see my nginx file. There is only one location and it is my app location. I tried to added some locations for keycloak I failed.
server {
listen 80;
server_name mydomain.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443;
## Add here your custom domain
server_name mydomain.com www.mydomain.com;
access_log /var/log/nginx/shinyproxy.access.log;
error_log /var/log/nginx/shinyproxy.error.log error;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /Certificates/sll.crt;
ssl_certificate_key /Certificates/ssl.key;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 600s;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Protocol $scheme;
}
}
This nginx file works to redirect from http://my-ip-address:8080
to mydomain.com
Then, when I want to go to the app, I have to login. However, as you can see on the browser, the url was not assigned as mydomain.com
. It shows me that url as
http://*.* .*.* :8081/auth/realms/shinyproxy/protocol/openid-connect/auth?response_type=code&client_id=shinyproxy&redirect_uri=http%3A%2F%[2Fmydomain.com](http://2fmydomain.com/)%2Fsso%2Flogin&state=858f3a51-b2ba-499c-bef4-804170f2f82b&login=true&scope=openid
I know I added some codes in nginx to fix that but I couldn’t find right solution.
I just want, when I go to mydomain.com
, it redirects me to mydomain.com/loginpage
for example. After successful authentication, the app opens on browser as redirected mydomain.com
I don’t know how to redirect two ports to one domain, how to configurate my nginx file for this case.
I’m waiting your responses,
thanks.