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
the api not work #316
Comments
Yes, I’ll take a look. |
Thank you! I host my GLPI on the same machine as One Time Secret, yet when I use the API from the One Time Secret site, it works. However, ultimately, I would like to have both locally. For One Time Secret, I left the configuration at default |
Nice, yeah that sounds like great setup. Do you have a web server / proxy running on that machine as well? Something like Nginx, Caddy, HAProxy etc. |
I have nothing else except for One Time Secret and GLPI on this VM. |
Kk, I got it sorted out. The issue you're having is related to SSL/HTTPS. The Onetime Secret ruby app doesn't handle SSL itself. So when making a request for https://myexampledomain.com/ (or https://myexampledomain.com:3000), that's how you get the error you're seeing.
Running a reverse proxyThe solution is to use a reverse proxy to handle the SSL termination. This is a common pattern in web applications. The reverse proxy is responsible for handling the SSL connection and then forwarding the request to the application server (in this case, the Onetime Secret app). Thin supports SSL itself so that's one option (see this gist). An easier option is to use Caddy as a reverse proxy. Here's a simple Caddyfile that you can use to get started:
Most importantly, Caddy automatically handles all of the SSL details for you (including generating the certificates). You can run Caddy as a service or in a container. Installing CaddyThe official instructions are great and should have details for whichever kind of system you run: Or in a nutshell, manually installing goes like this: # Download and install Caddy
curl -o caddy.tar.gz "https://caddyserver.com/api/download?os=linux&arch=amd64&idempotency=1234567890123"
tar xvf caddy.tar.gz
sudo mv caddy /usr/local/bin/
# Save your Caddyfile configuration to a file
cat << EOF > Caddyfile
https://myexampledomain.com {
reverse_proxy localhost:3000
log {
output stdout
}
header X-Content-Type-Options nosniff
header X-Frame-Options SAMEORIGIN
header Referrer-Policy no-referrer-when-downgrade
}
EOF
# Run Caddy with your configuration
caddy run --config Caddyfile --adapter caddyfile With that, you'll be able to access your Onetime Secret app over HTTPS at https://myexampledomain.com (or whatever domain you're using). |
Hey @delano
|
You're on the right track. :site:
:host: localhost:3000
:ssl: false The error |
When I try to use my self-hosted One-Time Secret API on the GLPI plugin, I get these errors:
[11/Apr/2024:15:24:05 +0200] "GET /img/favicon.png HTTP/1.1" 200 189 0.0036
'2024-04-11 15:25:14 +0200 Invalid request: Invalid HTTP format, parsing fails.
/var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/request.rb:86:in execute' /var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/request.rb:86:in parse'
/var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/connection.rb:39:in receive_data' /var/lib/gems/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in run_machine'
/var/lib/gems/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in run' /var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/backends/base.rb:75:in start'
/var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/server.rb:162:in start' /var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/controllers/controller.rb:87:in start'
/var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/runner.rb:203:in run_command' /var/lib/gems/3.0.0/gems/thin-1.8.2/lib/thin/runner.rb:159:in run!'
/var/lib/gems/3.0.0/gems/thin-1.8.2/bin/thin:6:in <top (required)>' /usr/local/bin/thin:25:in load'
/usr/local/bin/thin:25:in `
Can someone help me ?
The text was updated successfully, but these errors were encountered: