Let's say I have a domain "example.com". Right now, using caddy, I have configured example.com to be a proxy for a springboot application running on localhost 8080. How do you properly go to other routes within the application? For example, if I go to https://example.com/user, the url will be: example.com/user. but if I route from within the springboot app from there to /login (lets say using return new RedirectView("/login") at the end of the user route in the controller), it will redirect me instead to http:serverIpAdress:8080/login. How could I get this to route to https://example.com/login?
It is not an issue with Spring; Caddy needs to be configured properly as follows:
subdomain {
proxy / ipAddress:port {
transparent
}
}
1) be careful with the spacing in the caddyfile. I had originally tried this and it did not work, and I believe the reason is because i created the file like this:subdomain {
proxy / ipAddress:port { transparent }}
2) little bit of confusion that it did work, as from many places I have seen on the internet it appeared they removed transparent from the api
Related
I am wondering if there is a way to connect to ldap (389 server) through the apache 2.0.1 java ldap api and then continuously listen for changes to a specific attribute on a set of entries (in this case people with specific qualifications)?
Ideally I would like to run a query on ou=people,dc=test,dc=local
this might initially return
dn: uid=tester1,ou=people,dc=test,dc=local
givenName: tester1
dn: uid=tester2,ou=people,dc=test,dc=local
givenName: tester2
dn: uid=tester3,ou=people,dc=test,dc=local
givenName: tester3
If I then in the background changed tester3's givenName to userTester3 I would like to have a listener that would return some userModified event telling me that tester3 was modified.
As an example of what I would like to happen (psuedo code / non functioning code) I would like to do something along the lines of :
{
PersistentSearch ps = new PersistentSearch();
ps.setChangeType(ChangeType.MODIFY);
SearchRequest sr = ldaputility.createPersistentSearch(qualifiers, attributes, etc, ps);
PersistentSearchListener psl = new PersistentSearchListener(sr){
#Override
public void entryChanged(Entry e){
Log.info("The entry just changed");
}
}
}
There however from what I can tell in the apache 2.0.1 api is not any persistent search listener nor is there any type of listener for search requests in general and the search request gets results and then completes. I know that in the netscape api there is a search listener and that in the apache directory server api there is a persistent search listener. So what I am asking is does anyone know if the apache 2.0.1 ldap api supports a behavior where you make an initial query and any time the results of the query change you can have a listener that is notified of the new changes?
I unfortunately have no debugging code / output since I am not even sure what code to try right now.
It appears that by adding a PersistentSearch control (with changes only set to true and change types set to modifications) to the search request the ldap server won't ever set isDone to true on the search request so then the search request will continue to return the updates as they are available.
I downloaded XS_JSCRIPT14_10-70001363 package from Service Marketplace.
Please suggest me how to run this App Router Login form with localhost
I am trying with npm startcommand, but getting UAA service exception. How to handle from localhost.
When you download the approuter, either via npm or service marketplace you have to provide two additional files for a basic setup inside the AppRouter directory (besides package.json, xs-app.json, etc.).
The default-services.json holds the variables that tell the approuter where to find the correct authentication server (e.g., XSUAA). You have to provide at least the clientid, clientsecret, and URL of the authorization server as part of this file like this:
{
"uaa": {
"url" : "http://my.uaa.server/",
"clientid" : "client-id",
"clientsecret" : "client-secret",
"xsappname" : "my-business-application"
}
}
You can get this parameters, for example, after binding on SAP Cloud Platform, CloudFoundry your application to an (empty) instance of XSUAA where you can retrieve the values via cf env <appname> from the `VCAP_SERVICES/xsuaa' properties (they have exactly the same property names).
In addition, you require the default-env.json file which holds at least the destination variable to which backend microservice you want to send the received Json Web Token to. It may look like this:
{
"destinations": [ {
"name": "my-destination", "url": "http://localhost:1234", "forwardAuthToken": true
}]
}
Afterwards, inside the approuter directory you can simply run npm start which runs the approuter per default under http://localhost:5000. It also writes nice console output you can use to debug the parameters above.
EDIT: Turns out I was incorrect, it is apparently possible to run the approuter locally.
First of all, here is the documentation for the approuter: https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/01c5f9ba7d6847aaaf069d153b981b51.html
As far as I understood, you need to provide to files to the approuter for it to run locally, default-services.json and default-env.json (put them in the same directory as your package.json.
The default-services.json has a format like this:
{
"uaa": {
"url" : "http://my.uaa.server/",
"clientid" : "client-id",
"clientsecret" : "client-secret",
"xsappname" : "my-business-application"
}
}
The default-env.json is simply a json file holding the environment variables that the approuter needs to access, like so:
{
"VCAP_SERVICES": <env>,
...
}
Unfortunately, the documentation does not state which variables are required, therefore I cannot provide you with a working example.
Hope this helps you! Should you manage to get this running, I'm sure others would appreciate if you share your knowledge here.
I recently set up a website and pushed it to production using Digital Ocean. However, I noticed that for both SEO purposes and to make Facebook Share work appropriately, I should set up my server to redirect www. requests to non-www. I'm running Play! Java 2.3 with a PostgreSQL database and the default Netty server. Any advice would be greatly appreciated.
There are lots of ways of redirecting. I wouldn't say DNS-redirects are the correct and only way of doing it, it's one way. Google is just fine with you doing a 301 redirect with Play.
Here's one way of accomplishing it with Play! filters (scala):
object NonWwwFilter extends Filter {
def apply(f:RequestHeader => Future[Result])(rh: RequestHeader): Future[Result] =
if (rh.host.startsWith("www.")) {
Future.successful(Results.MovedPermanently("https://" + rh.host.substring(4) + rh.uri))
} else {
f(rh)
}
}
The right way to do it is to do in not on the framework/webserver side, but on the DNS-server side.
You can do it in DNS-management area of GoDaddy or any other domain name registrar.
I am using the Restlet Framework, but now I want to change to a proper server instead of using localhost.
I have already added my php files (they access the java files using the rest_server URL) to the server's folder and my java files as well, but I am not sure how to change the code so it identifies where the new location of the files is.
Here is the code from IdentiscopeServer (constructor empty):
public static void main(String[] args) throws Exception {
//setsup our security manager
if (System.getSecurityManager() == null){
System.setSecurityManager(new SecurityManager());
}
identiscopeServerApp = new IdentiscopeServerApplication();
IdentiscopeServer server = new IdentiscopeServer();
server.getServers().add(Protocol.HTTP,8888);
server.getDefaultHost().attach("", identiscopeServerApp);
server.start();
}
I guess that the correct line to change is the one with "Protocol.HTTP, 8888". If the address of my new server is http://devweb2013.co.uk/research/Identiscope, how exactly do I set this up? Is there anything else necessary for it to work apart from just moving the files to a folder in the server?
The IdensticopeServerApplication is the following:
public class IdentiscopeServerApplication extends Application {
public IdentiscopeServerApplication() {
}
public Restlet createInboundRoot() {
Router router = new Router(getContext());
//attaches the /tweet path to the TweetRest class
router.attach("/collectionPublic", CollectionPublicREST.class);
router.attach("/collectionPrivate", CollectionPrivateREST.class);
router.attach("/analysis", AnalysisREST.class);
return router;
}
}
Thank you in advance, it is my first time using this Framework.
If I understand you correctly, you just want to run your main() method as the server, correct? In this case, the code for main() needs to be in a location that -- when running -- can provide the service at http://devweb2013.co.uk/research/Identiscope. Since you haven't stated what kind of server you are putting the code, I can't say where the best place to put the code would be. I assume you have superuser privileges on your deployment server, since the URL you provided implies port 80 will be serving your Identiscope web service (port 80 is a privileged port on most OS's). So as an answer, I can only provide general information.
On your deployment server, port 80 must be free (i.e. nothing else should be acting as a web server on port 80 on that machine) and the IdentiscopeApplication must be running on port 80. To do that, you need only change the line:
server.getServers().add(Protocol.HTTP,8888);
to:
server.getServers().add(Protocol.HTTP, 80);
then run the application as a user that is allowed to start servers on port 80 (preferably NOT the superuser). If you haven't already, you will need to get Java running on your deployment server and make sure all Restlet libraries are in the classpath where you plan to run your application.
If I understand what you are trying to do, then this should do the trick.
I have a program that uses javax.xml.ws.Service to call a remote service defined by a WSDL. This program runs on the Google App Engine which, by default, sets the HTTP connection timeout to 5 seconds{1}. I need to increase this timeout value since this service often takes a long time to respond, but since this request is not being made with URLConnection, I cannot figure out how to call URLConnection.setReadTimeout(int){2}, or otherwise change the timeout.
Is there any way to globally set the HTTP connection timeout on the App Engine? And, for purposes of sharing knowledge, how would one go about solving this sort of problem generally?
{1}: https://developers.google.com/appengine/docs/java/urlfetch/overview#Requests
{2}: http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLConnection.html#setReadTimeout(int)
You could try setting the sun.net.client.defaultConnectTimeout and sun.net.client.defaultReadTimeout system properties documented here, e.g.
System.setProperty("sun.net.client.defaultReadTimeout", "30000");
System.setProperty("sun.net.client.defaultConnectTimeout", "30000");
EDIT
Sorry, just re-read and noticed this is on Google App Engine. I don't know for sure, but given the litigious relationship Google and Oracle have lately, I'm guessing GAE doesn't run the Oracle JVM. I'll leave this here in case someone else runs into a similar problem.
Try this:
Port port = service.getPort(endPointInterface); //or another "getPort(...)"
((BindingProvider) port).getRequestContext()
.put(BindingProviderProperties.REQUEST_TIMEOUT, 30);
See https://developers.google.com/appengine/docs/java/urlfetch/usingjavanet
You can do something like this to get a URLConnection:
URL url = new URL("http://www.example.com/atom.xml");
URLConnection tempConnection = url.openConnection();
tempConnection.setReadTimeout(10);
For App Engine with JAX-WS you have to set the request context (tested today with SDK 1.9.15). For normal machines you cannot go higher than 60s and would have to switch to the bigger machines (Bx) for better use a task queue.
For local testing you would normally use BindingProviderProperties.CONNECT_TIMEOUT and BindingProviderProperties.REQUEST_TIMEOUT, but they are not on the App Engine JRE White List and your code inspection might constantly warn you about that.
The equivalent strings can be used though:
com.sun.xml.internal.ws.connect.timeout
com.sun.xml.internal.ws.connect.timeout
For deployment to App Engine:
com.sun.xml.ws.connect.timeout
com.sun.xml.ws.request.timeout
A full example how to apply that to auto-generated code from JAX-WS 2.x, values have to be provided in milliseconds:
#WebEndpoint(name = "Your.RandomServicePort")
public YourServiceInterface getYourRandomServicePort() {
YourRandomServiceInterface port = super.getPort(YOURRANDOMSERVICE_QNAME_PORT, YourRandomServiceInterface.class);
Map<String, Object> requestContext = ((BindingProvider)port).getRequestContext();
requestContext.put("com.sun.xml.ws.connect.timeout", 10000);
requestContext.put("com.sun.xml.ws.request.timeout", 10000);
return port;
}