|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Does anyone have an idea how can I configure an apache virtualhost to point to different servers based on the URI?
I have an apache server that will serve as a reverse proxy for 3 backend servers. I want to be able to hit the backend server with URI. Example
https://apache.server/server1 -> will hit www.server1.com https://apache.server/server2 -> will hit www.server2.com https://apache.server/server3 -> will hit www.server3.com
If this is too hard and not possible, what is the better solution? Having 3 different Virtualhost and separate them with port? Having each Virtualhost with different port and hit them with the apache server with the same URL for 3 backend servers but change the port in order to point to the correct one?
Also worth mentioning that we will have an F5 that will act as load balancer to the apache server (or servers, we will be having 2 apache servers serving as reverse proxy for 3 backend servers... my head)
|
A better solution is to use nginx to replace both Apache and the F5 . nginx config format makes this super simple too.
location /server1 { proxy_pass http://www.server1.com/; }
|
Unfortunately it is not up to me to make decision of what we use. They made the environment and they are having configuring the Apache part...
|
On April 05 2016 02:00 WrathSCII wrote: Unfortunately it is not up to me to make decision of what we use. They made the environment and they are having configuring the Apache part...
Rarely is it too late for a well reasoned argument for switching infrastructure. If nginx can do everything you need, then all you need to do is convince the ones who make the decision that less time overall will be spent configuring/maintaining an nginx server compared to an Apache one.
But to answer your actual question, see this DO guide on mod_proxy
https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
|
Thanks for the post, but the post you mentioned above specifies how to do it for a single server and does not talk about using a URI to differentiate the backend servers.
|
Totally, unrelated:
![[image loading]](http://asset-8.soupcdn.com/asset/16066/4710_8841.png)
So... I heard you like callbacks...
|
On April 05 2016 04:44 Manit0u wrote:Totally, unrelated: ![[image loading]](http://asset-8.soupcdn.com/asset/16066/4710_8841.png) So... I heard you like callbacks... I am a nodejs developer and I find this funny.
One other thing: So I'm developing this html5 2d shooter game, when a player dies, the game just stops rendering image for that player and I realized a bug: When I kill an enemy in chrome, the killing bullet disappears on impact. But when I kill an enemy in firefox, sometimes the killing bullet disappears on impact, sometimes it does not. I solved the bug by making the player disappear after 50 milliseconds instead of 0 milliseconds but I still wonder why that stuff would happen in firefox but not chrome.
|
On April 05 2016 04:44 Manit0u wrote:Totally, unrelated: ![[image loading]](http://asset-8.soupcdn.com/asset/16066/4710_8841.png) So... I heard you like callbacks... Why is your indentation so inconsistent?
|
On April 05 2016 06:44 Acrofales wrote:Show nested quote +On April 05 2016 04:44 Manit0u wrote:Totally, unrelated: ![[image loading]](http://asset-8.soupcdn.com/asset/16066/4710_8841.png) So... I heard you like callbacks... Why is your indentation so inconsistent?
It isn't mine. My OCD would make me die for this.
|
Hey guys, I just finished a side project called ChartStream if you guys want to check it out: https://chartstream.herokuapp.com/
It lets you browse/stream complete music charts from various sources (mostly EDM). Want to load an entire Beatport chart and stream them in full? np!
I used react + redux and I gotta say that it's really fun building with it, compared to say something like angular
|
On April 05 2016 04:44 Manit0u wrote:Totally, unrelated: ![[image loading]](http://asset-8.soupcdn.com/asset/16066/4710_8841.png) So... I heard you like callbacks...
I really hope that column marker is placed at 80 lines...
|
On April 05 2016 04:33 WrathSCII wrote: Thanks for the post, but the post you mentioned above specifies how to do it for a single server and does not talk about using a URI to differentiate the backend servers.
At a certain point its up to you to figure out how to make stuff work as well. Mod_proxy is exactly what you need. You just need to dig a bit longer and find the right example to do what you want.
|
On April 05 2016 04:44 Manit0u wrote:Totally, unrelated: ![[image loading]](http://asset-8.soupcdn.com/asset/16066/4710_8841.png) So... I heard you like callbacks...
 
|
Finally thecodinglove got a gif that pretty much sums up everything I have to endure while dealing with all the legacy code:
|
Can someone help me understand this code in an android app, specifically the super.onActivityresult() call?
protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { // When an Image is picked if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK && null != data) { // Get the Image from data Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; // Get the cursor Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); // Move to first row cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); imgDecodableString = cursor.getString(columnIndex); cursor.close(); ImageView imgView = (ImageView) findViewById(R.id.imgView); // Set the Image in ImageView after decoding the String imgView.setImageBitmap(BitmapFactory .decodeFile(imgDecodableString)); } else { Toast.makeText(this, "You haven't picked Image", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG) .show(); } }
I don't understand the need for the super call here. Or what it would even accomplish.The code is from here: http://programmerguru.com/android-tutorial/how-to-pick-image-from-gallery/
|
On April 08 2016 15:37 Itsmedudeman wrote:Can someone help me understand this code in an android app, specifically the super.onActivityresult() call? + Show Spoiler +protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { // When an Image is picked if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK && null != data) { // Get the Image from data Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; // Get the cursor Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); // Move to first row cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0] ; imgDecodableString = cursor.getString(columnIndex); cursor.close(); ImageView imgView = (ImageView) findViewById(R.id.imgView); // Set the Image in ImageView after decoding the String imgView.setImageBitmap(BitmapFactory .decodeFile(imgDecodableString)); } else { Toast.makeText(this, "You haven't picked Image", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG) .show(); } }
I don't understand the need for the super call here. Or what it would even accomplish.The code is from here: http://programmerguru.com/android-tutorial/how-to-pick-image-from-gallery/ Me and my limited experience with android would go on and say this: The super handler might be doing some stuff in the background that has to be done so that the app doesn't break reliably whenever you do some random sequence of things in the same order.
If I'm wrong, feel free to correct me as well though
|
|
What Djagulingu and Nesserev said. In this case, the super call is not needed. In the general case, however, there are many Android methods that, when you override them, absolutely need to call super.method in order not to break. Activity.onCreate is the most obvious and well-known example.
As Nesserev said, this is always mentioned in the Android documentation, which is a far better source of information than trying to dig into the Android code yourself. For onActivityResult see here: http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)
|
On April 08 2016 17:04 Nesserev wrote:Show nested quote +On April 08 2016 15:45 Djagulingu wrote:On April 08 2016 15:37 Itsmedudeman wrote:Can someone help me understand this code in an android app, specifically the super.onActivityresult() call? + Show Spoiler +protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { // When an Image is picked if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK && null != data) { // Get the Image from data Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; // Get the cursor Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); // Move to first row cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0] ; imgDecodableString = cursor.getString(columnIndex); cursor.close(); ImageView imgView = (ImageView) findViewById(R.id.imgView); // Set the Image in ImageView after decoding the String imgView.setImageBitmap(BitmapFactory .decodeFile(imgDecodableString)); } else { Toast.makeText(this, "You haven't picked Image", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG) .show(); } }
I don't understand the need for the super call here. Or what it would even accomplish.The code is from here: http://programmerguru.com/android-tutorial/how-to-pick-image-from-gallery/ Me and my limited experience with android would go on and say this: The super handler might be doing some stuff in the background that has to be done so that the app doesn't break reliably whenever you do some random sequence of things in the same order. If I'm wrong, feel free to correct me as well though You're correct Djagulingu; when you overwrite a function of a superclass, you often EXTEND its behaviour. In such a case, it often suffices to call the overwritten method at some point, and write your added functionality before and/or after the call to the overwritten method; but I think itsmedudeman already knew that. Here's the class definition, method can be found at around line 5000. https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/Activity.javaIf you look at the implementation of the Activity class (something that you normally shouldn't do to make these decisions), you can see that it's just an empty method. This is probably done so that you don't have to implement it yourself when using Activity as a base class, and don't need to use it. If it was a required call (now or in the future), the documentation should've mentioned it, but it doesn't. So feel free not to call it, or do call it... it doesn't matter.
I think your assumptions would be true for most platforms, but not for android. This one example might be inconsequential now, but, the docs are not always in line with the code.
This link seems to suggest that it is required in some cased.
All in all I'm not a big fan of how android handles the super calls, but its the way the framework works and therefore you have to play by their rules.
A short explanation on calling super in android.
|
|
|
|
|