Wildfly 9 - Want to expose 1 app to internet and another to intranet - wildfly

Im working on Wildfly 9 and want to expose 1 app to intranet 10.x.x.x and another to Internet on 200.x.x.x
The question is how you do this in standalone.xml?
Thanks.

You will need two standalone instances.
It's not possible separate aplications by IP.
This will bind all your apps for the configured IP:
<interfaces>
<interface name="public">
<inet-address value="${jboss.bind.address:10.x.x.x}"/>
</interface>
</interfaces>
You can add other interface, but you can't apply that for only one app.

While this may not be the answer you want I've done what you're trying to do by fronting Wildfly with Apache. If you take a look at the IP based virtual host docs, you can have Apache handle the virtual host switch. Basically your Apache .conf file will have something like:
<VirtualHost 10.x.x.x:80>
ServerName internal.host.name
ProxyPreserveHost on
ProxyPass / http://localhost:8080/internal-app
ProxyTimeout 360
</VirtualHost>
<VirtualHost 200.x.x.x:80>
ServerName external.host.name
ProxyPreserveHost on
ProxyPass / http://localhost:8080/external-app
ProxyTimeout 360
</VirtualHost>
This is using HTTP proxying - AJP may be a bit faster but I've always found the HTTP version easier to implement and maintain.
Again, the downside is that this requires another package to setup and maintain. Apache is extreamly well supported in the community but that may not help if you're the one doing the work.
Note that this requires the proxy and proxy_http Apache modules to be enabled. If you go this route, let me know you O/S and I can tell you how to enable them.

Related

How to run a service on subdomain instead of port on AlmaLinux with Cpanel?

I have a version of keycloak running on my AlmaLinux server. This service runs on port 8080. I can access it using <SERVER-IP>:8080. I however, want to access the service using mysubdomain.mymaindomain.com. This way, the user is not confronted with port-numbers, and I suppose using autoSSL is easier (I cannot get it to work on a different port).
I tried multiple things.
The first (I know, very sketchy) was rerouting using htaccess. I made a rewrite condition that looped to localhost:8080. At first glance this worked, but redirects did not work. I suppose this is, since the service thinks it runs on 'localhost:8080' (what it of course does), and thus redirects (on the browser side) to localhost:8080/home for example.
The second thing I tried was adding this code to the virtualhost config file.
I added this using the WHM environment in the server configuration > apache configuration > include editor. There I tried both 'Pre Virtual Host Include' and 'Post Virtual Host Include' (Originating from here).
<VirtualHost *:80>
DocumentRoot "/public_html/keycloak_public"
ServerName mysubdomain.mymaindomain.com
# Other directives here
</VirtualHost>
That did not work, I found out I had to use a proxy. So I appended the following code behind the former part. (Originating from here).
<VirtualHost *:80>
ServerAdmin me#mymaindomain.com
ServerName mysubdomain.mymaindomain.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
However, when I go to mysubdomain.mymaindomain.com this still loads the empty directory, instead of the equivalent of :8080.
According to the above mentioned thread, I have to enable proxy somehow, but I did not find a way to do so in Cpanel, so I kind of assumed it was enabled (I'm sorry). Can that be the problem, or should I look somewhere else in order to fix this problem?
The solution turned out to be replacing the * with the server-ip!

What's happening with search.cpan.org and how to install an redirector?

EDITED question
It last 2 weeks search.cpan.org was down many times. Yes i know here is a metacpan, but zilion of links from the net points to search.cpan.org so the metacpan isn't the "only" solution.
Want make a local redirector, by entering to my /etc/hosts something like:
search.cpan.org 127.0.0.1
and run an simple PSGI (or Apache) server on localhost:80 what should done the redirects. So the requests for "search.cpan.org" would be processed at "localhost" with the script and it should return valid 302 responses and redirect to metacpan.org.
#Mpapec pointed to mcpan.org - what doing exactly for what i looking, so now enoudh redirect every request to "mcpan.org".
After edited my /etc/hosts as above, tried the next apache config:
<VirtualHost *:80>
ServerName search.cpan.org
RedirectPermanent / http://search.mcpan.org/
</VirtualHost>
but doesn't work. Would be nice to get some help. Or an alternative, a simple app.psgi script would be nice too.
So, the questions are:
how to configure local apache for redirects search.cpan.org -> search.mcpan.org
or how to write a simple app.psgi for running it with plackup -p 80 for the same function
and one offtopic question:
know anyone something about the status and a future of search.cpan.org?
search.cpan.org is run by Graham Barr. For questions about websites that he runs, you'll have to contact him.
The source code is not available. That's why MetaCPAN sprang up.
I wouldn't bother with a redirector. Maybe a Greasemonkey script, though :)
I was an configuration error in my apache. The next works.
1.) edit /etc/hosts and add a line IP.OF.YOUR.LOCAL.WEBSERVER search.cpan.org, e.g.:
127.0.0.1 search.cpan.org
2.) for apache (i have 2.4) into httpd.conf enter
<VirtualHost *:80>
ServerName search.cpan.org
Redirect / http://search.mcpan.org/
</VirtualHost>
3.) Be sure than your apache listening on port 80 e.g. have a directive
Listen 80
With the above, every request to "search.cpan.org" get redirected to "search.mcpan.org" and the "mcpan" redirects it to "metacpan". It is suboptimal, would be nicer to have a set of rewrite rules what redirects directly into "metacpan", but works.

How to find, properly configure MS Team Foundation server?

I have a win7 virtual machine, that has a postgresql installed. There is an (apache) Enterprise DB on my localhost:8080.
I have installed MS Team Foundation Server successfully, and I can see from the management console, that my "DefaultCollection" is online.
Browsing for localhost:8080/tfs or localhost:8080/tfs/DefaultCollection returns a 404 not found error. I had no say on what port I would like to use,
Can you help me find the proper address for this team foundation server? Or tell me how to configure it properly. (I am unfamiliar with this server configuring world, please provide detailed commands or material.)
It sounds like you must've installed PostgreSQL using the one-click installer for Windows, then ran the StackBuilder and installed Apache using StackBuilder.
If so, it's just an ordinary Apache install that you can configure just like normal. You need to either stop and disable any running Apache service in the Services control panel (services.msc).
Alternately, if you wish to continue using it but on a different port, edit the Apache configuration to set the Listen directive to something other than 8080 and change any NameVirtualHost and VirtualHost directives to use the new port, eg:
Listen 8080
NameVirtualHost *:8080
<VirtualHost *:8080>
... blah blah ...
</VirtualHost>
would become:
Listen 8181
NameVirtualHost *:8181
<VirtualHost *:8181>
... blah blah ...
</VirtualHost>
See:
Apache - Virtual Hosts
Apache - Listen
You can find the location of the Apache config file by examining the command that's being used to run Apache. That might be a batch file to start it and stop it, or a service command in the services control panel. It'll probably be called httpd.conf or apache2.conf..
They are 'proper' addresses, but unless the person trying to open the webpage has a valid TFS account then you will not be able to access TFS through the website.
Can you access: http://localhost:8080/tfs/web?
Is your Windows login allowed to access TFS server?
As Craig mentioned, you don't hive any information that could help diagnose what you're trying to achieve. Why are you trying to access TFS through its web endpoints? Did you make sure MSSQL and IIS are installed on the machine? Why have you got apache and postgresql installed on a ALM server that doesn't require them?
TFS is a very complex product, and even though the development team has made huge strides in making it easy to install, it's no small task to get a server working.

how to view "localhost" on my iPod touch

I have a website I am building on localhost:
http://localhost/my-website
I need to test it on my iPhone, but I'm not sure how to go about it. Do I just change my httpd-vhosts.conf file, and, if so, what are the settings?
Assuming that your development machine is called my-macbook-pro, you should just be able to navigate to http://my-macbook-pro.local/mywebsite on your iPhone.
To expand slightly on Richard J. Ross III's answer, "localhost" is a name used to refer only to the local computer. In order for your iPhone to be able to access content on that machine it must:
Have an IP address on the same network as the server machine.
This can be achieved by connecting the iPhone to a wireless access point that is on the same network as the PC, or by creating an ad-hoc wireless network between the two devices.
Respond to HTTP requests from network clients.
Assuming the server and the iPhone are on the same network, it should be possible for traffic to flow between them. However in order for your web content to be visible to the iPhone, the web server must also be configured to respond to requests made to the server machine's IP address.
This is not normally a problem as web servers are commonly configured to respond to HTTP requests sent to any of the machines IP addresses. It is possible that a server could be configured to only respond to local requests, however this is not a typical default setting
How you check or modify this setting is dependent upon the HTTP server software you are using. As this information is not specified I will include instructions for Apache2 as this is a very common choice of HTTP server.
Apache's Listen Directive
Apache's main configuration file is httpd.conf and it is located in the conf subdirectory of your Apache directory. The location of your Apache root directory will vary depending upon what operating system you are using and whether or not a custom location was chosen at installation.
The httpd.conf file contains a directive named Listen which controls the interface (IP address and port) on which Apache listens for incomming HTTP requests.
The default form of this directive is commonly
Listen 80
This specifies that the machine will respond on any of it's IP addresses to requests made on port 80, which is the default port for HTTP traffic.
You can modify the Listen directive to use any address associated with the machine including the loopback address (127.0.0.1) which the name localhost resolves to.
If Apache is set up to only listen on the loopback address then your server machine will only respond to requests made on the local machine. In this configuration, your Listen directive will look something like:
Listen 127.0.0.1:80
If this is the case, you will need to change to either listening on all addresses, as in the example above, or listening only on the address used by the iPhone to communicate with the server machine.
100% working solutions
(for linux + apache + vhosts)
If you are using vhost (several sites on the same server apache) the next several tips can help you view your local websites on mobile:
1) VHOST edit -You should go to /etc/apache2/sites-available/ on your server. There can be several files .conf, each file contain a virtual host configuration for apache. Default file will look like 000-default.conf. Open it (or another one) with admin permissions sudo. In that file you should see something like this:
<VirtualHost *:80>
ServerName auction.dev
ServerAdmin test#test.com
DocumentRoot /var/www/public_html/html
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
</VirtualHost>
2) XIP.IO - this special service (its totally free) can help you. You should add to .conf file next line - ServerAlias auction.dev.*.xip.io, after this operation your file will look like this:
<VirtualHost *:80>
ServerName auction.dev
ServerAlias auction.dev.*.xip.io
ServerAdmin test#test.com
DocumentRoot /var/www/public_html/html
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
</VirtualHost>
After editing you should save this file and restart apache with command sudo apachectl restart.
3) View from mobile - You need to know ip of your server, in my situation ip = 192.168.1.247. Now in your mobile browser just type auction.dev.192.168.1.247.xip.io and you should see your local website.
I'm working with xampp. localhost works on port 8080.
I just find my ip with ipconfig and surf to http://10.0.0.1:8080.
That easy!
If you just want a better feel of the native behavior instead of just browser dev tools you can use the iOS simulator and type localhost:xxxx in safari app.
For OSX, go to System Preferences / Sharing. There, you can find and change the name of your computer. In the same section, you also have to enable "Internet Sharing" service with "iPhone USB" port.
Then you can view your website at http://{ computer_name }.local/my-website.
When you connect your ipod with the cable to your macbook the device appears in safari on your mac in the menu under developers. When you click this option you can see exact the same as you can on your ipod.
Following these steps worked for me:
https://mtm.dev/iphone-localhost-mac
It is based on Internet Sharing via USB and setting & using the device_name which is then used as mentioned as <device_name>.local:<port>

What must I do to ensure that a web server (Apache) running on a machine is not accessible to the outside world?

I would like to use my laptop as a web development (PHP, Python, etc.) machine, but I'm hesitant to do this unless I can ensure that it can not be accessed by the outside world.
I'm guessing that something more than a firewall is necessary, such as configurations to the Apache configuration files, but I'm not sure what else I would need to be 100% sure it's locked down tightly.
in the configuration file, change the LISTEN directive to only listen on the loop back address:
Listen 127.0.0.1
You need to configure the server daemon to only bind to localhost using the Listen directive like this:
Listen 127.0.0.1
An alternative is to configure access control for the main server like this
<Directory "/var/www/localhost/htdocs">
AllowOverride None
Deny from all
Allow from 127.0.0.1/255.0.0.0
</Directory>
Remember to put the root directory of your server in the Directory Directive.
Install a firewall and close all external ports but those who you want to use. If you are using Linux, there are nice frontends for iptables such as firestarter, if you use OS X there is an integrated firewall and Windows has one too. :)
But yes, the Firewall is the way to go. (Or you can tell Apache to listen on 127.0.0.1:80 only)
A firewall should be sufficient. Just make sure that you run apache in a non-standard port (typically 8080) and make sure your firewall blocks outside access to that port.
Firewall should be enough. But you can use the Listen directive as well.
A firewall will do just fine. But if you won't settle for just a firewall you can configure apache to just listen on your loopback device, or tell it to just accept connections from a set of addresses on your lan. The first method is easier, but that way you can access the web pages only from the machine apache is running on.
Put a router between you and the internet, and don't forward any ports to your laptop. That way anyone trying to access the laptop hits the router and can't get any further.
You can forward ports to your main machine (or just put the main machine in the DMZ) if you need it to be available to incoming connections.