Pushing Actix-web code to AWS Lightsail

Hi,
At: Small actix-web code, we have the following form action:
This whole code works fine on my system but when I create an image and push it to Amazon Web Services (AWS) Lightsale (https://myrust1.0lr0hfsbv4dso.eu-west-2.cs.amazonlightsail.com/), the form loads but pressing submit button throws an error "This site can’t be reached", instead it should say "Authentication Failed!". This is because it does not recognise the path and port number given in the 'form action'. Could someone please assist me what needs changing so that it works without error inside AWS Lightsail too?

1 Like

The code example you gave has this line for the rust binary:

[...]
.bind("127.0.0.1:8088")?
[...]

And this line in the HTML:

<form method="post" action="http://127.0.0.1:8088">

.. and when I visit the page and click 'submit', it redirects me to http://0.0.0.0:8208/sec_authentic

Obviously, the above address does not show anything. It points to my personal laptop. Shouldn't it point towards something like https://myrust1.0lr0hfsbv4dso.eu-west-2.cs.amazonlightsail.com/sec_authentic or whatever?

Also note, I think you might need to change

.bind("127.0.0.1:8088")?

to

.bind("0.0.0.0:8208")?

or something similar so it can be accessed outside of the instance you binary is running on?

1 Like

Many thanks Fabio. Its now fixed with your suggestion of setting "https://myrust1.0lr0hfsbv4dso.eu-west-2.cs.amazonlightsail.com/sec_authentic" as the form action. Feeling great!
One question though: How did you get to know that I have a .bind("127.0.0.1:8088")? statement in my code.
Thanks

1 Like

Happy to help. My inference was that you did something similar to the example you linked: https://users.rust-lang.org/t/small-actix-web-code/48661

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.