Request to Spring Boot Application Local vs Prod - spring-boot

I have a Spring Boot Application without property server.servlet.context-path configured in my application.yml.
For access anyone endpoint local (dev), I make a request without context path.
Example:
curl --location --request GET 'http://localhost:8080/foo/bar'
Now think so, we have the context path or application with name app.
In the production environment I need to make the request with the context path.
Example:
curl --location --request GET 'http://server.com/app/foo/bar'
I have already configured environment in Postman:
ENVIRONMENT
VARIABLE
CURRENT VALUE
LOCAL
host
http://localhost:8080
PROD
host
http://server.com
To make the request in Postman, I use:
LOCAL: {{host}}/foo/bar
PROD: {{host}}/app/foo/bar <-- See that here I need pass the context path.
I would like to change the environment from Postman without add or remove the context path name of request.
Something as optional variable for context path.
Someone help me.

You can include /app path in your Production Environment {{host}} variable, and keep same paths when switching between environments.

Related

Terraform throwing error:error configuring Terraform AWS Provider: The system cannot find the path specified

I was facing issue with running aws command via cli with certificate issue. So as per some blogs, I was trying to fix the issue using setx AWS_CA_BUNDLE "C:\data\ca-certs\ca-bundle.pem" command.
Now even after I removed the variable AWS_CA_BUNDLE from my aws configure file, terraform keeps throwing the below error on terraform apply.
Error: error configuring Terraform AWS Provider: loading configuration: open C:\data\ca-certs\ca-bundle.pem: The system cannot find the path specified.
Can someone please tell me where terraform/aws cli is taking this value from and how to remove it? I have tried deleting the entire aws config and credential files still this error is thrown, uninstall aws cli and reinstalling.
If its set in some system/environment variable, can you please tell me how to reset it to default value?
The syntax to add ca_bundle variable to config file is wrong.
Your config file should look like this
[default]
region = us-east-1
ca_bundle = dev/apps/ca-certs/cabundle-2019mar05.pem
But as I understand you want to use environment variable (AWS_CA_BUNDLE).
AWS_CA_BUNDLE:
Specifies the path to a certificate bundle to use for HTTPS certificate validation.
If defined, this environment variable overrides the value for the profile setting ca_bundle. You can override this environment variable by using the --ca-bundle command line parameter.
I would suggest remove environment variable (AWS_CA_BUNDLE) and add ca_bundle to config file. The delete .terraform folder and run terraform init
Go environment variables and delete the environment variable created by AWS_CA_BUNDLE. Shut down Terminal and again start. Run the commands now it will work properly.

Install collection dependencies in ansible with differing proxy settings

Problem: I want to install a collection via ansible-galaxy, but one needs a proxy and the other one does not
galaxy.html of the needed collection:
dependencies:
community.docker: 2.4.0
git+https://gitlab.test.org/collections/test: master
In this example, community.docker needs a proxy to be installed, the other one fails if a proxy is set.
Is there a possibility to unset the proxy or set the proxy for a dependency in the galaxy.yml file?
Setting the no_proxy environment variable on the controller is a fine solution for this problem.
export no_proxy=gitlab.test.org
It can get rather aggregious to do this though if you have similar names for your gitlab instances, but worked for me.

How can I override quarkus.security.users.embedded.users on docker run command line?

I have a quarkus based webapp that uses Basic Authentication with Embedded Realm Configuration. The webapp runs in a docker container. The authentication properties are specified in application.properties like this:
quarkus.http.auth.basic=true
quarkus.security.users.embedded.enabled=true
quarkus.security.users.embedded.plain-text=true
quarkus.security.users.embedded.users.test=mypass
quarkus.security.users.embedded.roles.test=admin
I would like to override quarkus.security.users.embedded.users.test to specify a password at docker runtime.
I tried to do this by overriding the quarkus property using an environment variable at docker runtime.
docker run -p 9999:9999 -e QUARKUS_SECURITY_USERS_EMBEDDED_USERS_TEST=newpasswd mywebapp
This does not work. When I access mywebapp using http://locahost:9999 I must login using test/mypass. I expected to login using test/newpasswd.
Any help greatly appreciated.
I suggest you report an issue for this problem. While Quarkus won't be able to "enumerate" any new users from environment variables (the correct property names cannot be deduced), I think it should still be possible to override the password of a user that has already been specified in application.properties using an environment variable like you try to do.

Specify user name and passoword in JFrog Artifactory URL in order to avoid the prompt for credentials

I have a JSON file which I have in maven artifactory.
I need to put the URL in another web application which would directly point to this JSON file. But then the issue I am facing is, due to the authentication issue, it is not able to read it.
So is it possible to specify the credentials directly in the URL so that we can avoid the authentication issue and the other web application could read the JSON file directly.
The web application needs the URL which would return a JSON file.
I'm not a Maven expert, but you can add the credentials in the URL. In the sample below I've used curl to show how that would work.
For example, this curl command would upload a file (download would work the same, just without the -T <MyFileName>)
curl -uadmin:<PASSWORD> -T <MyFileName> "http://jfrog.local/artifactory/generic-local/bla"
If I want to add the credentials into the URL I'd end up with
curl -T <MyFileName> "http://admin:<PASSWORD>#jfrog.local/artifactory/generic-local/bla"
Both curl commands do the the same, the difference is where I have the credentials.

multiple parameters not getting passed when I start my spring boot application in command line

I want to override certain properties during deployment of my spring boot application.
when I try the following it works
sudo /etc/init.d/myapp start --app.env=prod
I see the app.env is correctly set to prod (my /health just echoes this values)
however when I set more than one property it did not work,
sudo /etc/init.d/myapp start --app.env=prod --version=2.3.4
I see only app.env is correctly set. the version value is not overridden.
why is it so? what is the right way to pass multiple parameters.
NOTE: I want to pass username and password for datasources. but for testing purposes, I kept it simple to override these properties.
You would want to read the section around Customizing the startup script. Specifically that you can include a myapp.conf file beside the jar file. In that .conf file is a JAVA_OPTS variable. You would then use -Dapp.env=prod -Dversion=2.3.4

Resources