3

Is it possible to start play framework 2.3 on localhost ? I have tried

./activator run -Dhttp.address=127.0.0.1 -Dhttp.port=9007

./activator run -Dhttp.address=localhost -Dhttp.port=9007 # From 

another stackoverflow thread ./activator start -Dhttp.address=127.0.0.1 -Dhttp.port=9007

But nothing works everytime I am receiving

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9007

related thread Force Play Framework to listen on localhost only

Community
  • 1
  • 1
Oleg
  • 3,080
  • 3
  • 40
  • 51

4 Answers4

2

According to the documentation provided by Play Framework the way you're going at it only works for Netty based instances of Play. I presume you are using Akka-Http, if you're not however, please report this as a bug to the Play Framework team.

You might also want to read up on this, it covers on how to set Play Framework up to work behind a proxy such as Nginx or Apache.

One last thing, it is generally recommended to only expose the absolute necessary ports to the outside internet, preventing attackers from exploiting possible weak points in your system. I advice you, doesn't matter if you get this in working order or not, to also install some good IPTables software on your box and block the port your local, behind the firewall, Play instance is running on.

Martijn
  • 2,268
  • 3
  • 25
  • 51
1

Instead of: ./activator run -Dhttp.address=127.0.0.1 -Dhttp.port=9007

reverse the arguments ("-D" option before "run"):

activator -Dhttp.address=127.0.0.1 run

--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /127.0.0.1:9007
(Server started, use Ctrl+D to stop and go back to the console...)
pilcrow
  • 11
  • 2
0

Just do activator "run 9007" (assuming activator is in your PATH, which is the norm).

See also:

Community
  • 1
  • 1
acjay
  • 34,571
  • 6
  • 57
  • 100
0

Try this

./activator "run 9007"

you can access your application through localhost by this. you can write any port you want in place of 9007

Rakesh Chouhan
  • 1,196
  • 12
  • 28
  • it listens on 0.0.0.0 by default . And I need really 127.0.0.1 – Oleg Jan 16 '15 at 10:09
  • Loopback address is a special IP number (127.0.0.1) that is designated for the software loopback interface of a machine. try this link http://stackoverflow.com/a/20778887/1478261 – Rakesh Chouhan Jan 16 '15 at 11:08
  • 0.0.0.0 means that my site is accessible from outside, 127.0.0.1 means that only local services can connect to it. My play framework is behind ngnix proxy, and I want to avoid direct access from internet to play - I can do it with iptables but seems to be a more simple way. – Oleg Jan 16 '15 at 11:22
  • Then I think IP table is a better option. – Rakesh Chouhan Jan 16 '15 at 11:48