Skip FOLIO Project Navigation

Help! Replace localhost by hostname on the demo box is INVALIDE, and how do I customize the okapi url?

Hi friends, :pray:

I created a demo application on a PC.

My environment:

  • Windows 10
  • Vagrant 2.2.18
  • VirtualBox 6.1
  • release-core FOLIO Iris Release (12 July 2021, Hot Fix #2)

I can use the local address localhost:3000 and the account (diku_admin/admin) to log in normally, and everything looks fine.

Problems encountered:

In order to be able to access my local web service on the public network, I used frp (a reverse proxy program) and configured it accordingly.

I can access the local FOLIO service through http://My-server-domain-name:81, and I can enter the login page, but I cannot log in to the system.

I observed through chrome devtools that this problem is caused by the inaccessibility of the request (okapi url http://localhost:9130 ).

I tried to modify /etc/folio/okapi/okapi.conf, but it still doesn’t work.

I tried to configure Vagrantfile with the method on the Internet, but it didn’t work.

Vagrant.configure("2") do |config|
  config.vm.box = "myfolio"

  config.vm.provision "shell", env: {
    "OKAPI" => "http://folio-okapi.my-server-domain:81"
  }, inline: <<-SHELL
    set -e
    systemctl stop okapi-deploy 2>/dev/null || systemctl stop okapi
    sleep 10
    docker ps -a -q | xargs --no-run-if-empty docker rm -f
    rm -rf /etc/folio/stripes/output
    /etc/folio/stripes/build-run
    systemctl start okapi-deploy 2>/dev/null || systemctl start okapi
  SHELL
end

Here, okapi url http://folio-okapi.my-server-domain:81 is mapping to localhost:9130.

Link: https://github.com/folio-org/folio-ansible/blob/master/doc/index.md#replace-localhost-by-hostname-on-the-demo-box

Can anyone give me some advice and help, thank you very much. :pray: :pray: :pray:

By the way, I am a software engineer from Wuhan, China. I am very interested in the FOLIO project.

I am currently studying and researching it.

I hope that I can also contribute to the project in the near future.

Beast Regards,
Kai

You need to proxy to both ports: 3000 and 9130.
Example:
“OKAPI” => “http://my-server-domain:9130
http://My-server-domain-name:81 → 3000
http://My-server-domain-name:9130 → 9130

Hi julianladisch,

Thank you for your reply.

Yes, I did this.

My frp client config: frpc.ini

[web]
type = http
local_port = 3000
custom_domains = folio.my-domain

[web9130]
type = http
local_port = 9130
custome_domains = okapi-folio.my-domain

I can access http://folio.my-domain (login page), but log in is failed.

And from the frp management background, you can see that the ports status of 3000/9130 is online.

So I think the configuration of the frp reverse proxy is correct and it works.

It may be a problem with the FOLIO okapi config or the Vagrant config.

What do you think?

Thanks a lot!

Your frpc.ini snipped doesn’t mention server_port.
If it defaults to 80 you need to set

"OKAPI" => "http://okapi-folio.my-domain:80"

Thank you for your guidance. I’ll try again.

Hello @kzeng
Hope all is well with you.
So, do you try it?
If it is works for you, could you share with us?
Thank you.

Hi @kanthony

Thank you for your attention. Have you had the same problem as me?

I haven’t started verification yet, but once I’m done, I’ll share it on the forum for the first time.

Yes.
I think something should be change on docker composer.

@kanthony , @julianladisch

The steps to customize localhost as your host domain name in a local VM environment have been validated.

  1. My PC hardware and software environment:
	RAM: 16.0 GB (15.4 GB Available) 
	CPU: Intel (R) Cole (TM) i5-6300U CPU @ 2.40GHz 2.50GHz
	Windows10
	Vagrant 2.2.18
	VirtualBox 6.1
	Google Chrome Version 94.0.4606.61 (Official Build) (64-bit)
    folio release core v1.0.0-20210712.6632
  1. Start the frps service on the public network, frps -c frps.ini

frps.ini

[common]
bind_port = 7000
kcp_bind_port = 7000
vhost_http_port = 81
token = your-token
  1. Start the frpc client on the local PC, frpc -c frpc.ini

frpc.ini

[common]
server_addr = Public-IP-Address
server_port = 7000
token = your-token

[web]
type = http
local_port = 3000
custom_domains = folio.your-domain-name

[web9130]
type = http
local_port = 9130
custom_domains = folio-okapi.your-domain-name
  1. Modify Vagrant config file, Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "myfolio"

  config.vm.provision "shell", env: {
    "OKAPI" => "http://folio-okapi.your-domain-name:81"
  }, inline: <<-SHELL
    set -e
    systemctl stop okapi-deploy 2>/dev/null || systemctl stop okapi
    sleep 10
    docker ps -a -q | xargs --no-run-if-empty docker rm -f
    rm -rf /etc/folio/stripes/output
    /etc/folio/stripes/build-run
    systemctl start okapi-deploy 2>/dev/null || systemctl start okapi
  SHELL
end
  1. Restart the VM for the configuration to take effect

vagrant halt

vagrant up

It is important to wait about 5 minutes for all modules to start.

  1. Browser access

http://folio.your-domain-name:81

diku_admin/admin, login all OK.

Thanks,
Kai

Another way:

  1. enter folio stripes config directory
    cd /etc/folio/stripes/

  2. mpdify the script build-run, repalce OKAPI url (default: ocalhost:9130) with your url.

  3. run build-run

  4. copy the output file under the path /etc/folio/stripes/output to docker image dir

e.g.

docker cp /etc/folio/stripes/output/bundle.13e120537dd2e7db1d8f.js stripes_stripes_1:/usr/share/nginx/html/bundle.13e120537dd2e7db1d8f.js

  1. VM reload & start frpc

It works.

Special thanks,@beesoft.