Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No static content serving on test domain #140

Closed
dasmurphy opened this issue Dec 11, 2017 · 14 comments · Fixed by #234
Closed

No static content serving on test domain #140

dasmurphy opened this issue Dec 11, 2017 · 14 comments · Fixed by #234

Comments

@dasmurphy
Copy link

dasmurphy commented Dec 11, 2017

I'm coming from pow and wanted to use puma-dev now for me. I use a Mac with OSX 10.11.

I uninstalled pow with curl get.pow.cx/uninstall.sh | sh.

I installed puma-dev with:
brew install puma/puma/puma-dev

puma-dev -V gives Version: 0.11 (go1.9.1).

Then i created a ~/.puma-dev folder and following in it:

/testdomain/
/testdomain/public/
/testdomain/public/index.html

I started puma-dev with this command for testing:
sudo puma-dev -d dev:test -http-port 80 -https-port 443 -debug

When opening http://testdomain.test i get: unexpected exit as error.

I looked at the console and saw this:

* Directory for apps: /Users/murphy/.puma-dev
* Domains: dev, test
* DNS Server port: 9253
* HTTP Server port: 80
* HTTPS Server port: 443
! Puma dev listening on http and https
2017-12-11T16:53:28.782041466+01:00: GET '/' (host=testdomain.test)
! Booting app 'testdomain' on socket /Users/murphy/.puma-dev/testdomain/tmp/puma-dev-11110.sock
testdomain[11117]: Puma starting in single mode...
testdomain[11117]: * Version 3.11.0 (ruby 2.0.0-p648), codename: Love Song
testdomain[11117]: * Min threads: 0, max threads: 5
testdomain[11117]: * Environment: development
testdomain[11117]: ERROR: No application configured, nothing to run
! Killing 'testdomain' (11117)
* App 'testdomain' shutdown and cleaned up
! Detecting app 'testdomain' dying on start
2017-12-11T16:53:30.408110095+01:00: GET '/favicon.ico' (host=testdomain.test)
! Booting app 'testdomain' on socket /Users/murphy/.puma-dev/testdomain/tmp/puma-dev-11110.sock
testdomain[11118]: Puma starting in single mode...
testdomain[11118]: * Version 3.11.0 (ruby 2.0.0-p648), codename: Love Song
testdomain[11118]: * Min threads: 0, max threads: 5
testdomain[11118]: * Environment: development
testdomain[11118]: ERROR: No application configured, nothing to run
! Killing 'testdomain' (11118)
* App 'testdomain' shutdown and cleaned up
! Detecting app 'testdomain' dying on start

Here are my questions:

  1. Did i miss something or is puma-dev not able to share static sites without config? (Issue #44)
  2. Why is puma started at all, since i think puma-dev should share the contents?

Thanks for all the help you can get me. I take all ideas :)

PS: Sorry for my bad english ;)

@chriso0710
Copy link

chriso0710 commented Jan 23, 2018

Same problem here. Coming from pow I like pows ability to serve static content.
If I understand #44 correctly puma-dev should be able to serve static files from the public directory. This does not seem to work for me. Why does puma-dev need puma for serving static files?

I have a link to public (jekyll _site) in my .puma-dev dir:

~/.puma-dev/hayvalley$ ls -al
lrwxr-xr-x  1 co  staff   34 21 Nov  2016 public -> /users/co/projects/hayvalley/_site

When trying to connect to http://hayvalley.test I am getting a

$ curl -i -L --head http://hayvalley.test
HTTP/1.1 500 Internal Server Error
Date: Tue, 23 Jan 2018 11:22:28 GMT
Content-Length: 15
Content-Type: text/plain; charset=utf-8

Puma-dev log:

* Directory for apps: /Users/co/.puma-dev
* Domains: test
* DNS Server port: 9253
* HTTP Server port: inherited from launchd
* HTTPS Server port: inherited from launchd
! Puma dev listening on http and https
! Booting app 'hayvalley' on socket /Users/co/.puma-dev/hayvalley/tmp/puma-dev-17433.sock
hayvalley[17445]: bash: no job control in this shell
hayvalley[17445]: Hello from .bash_profile
hayvalley[17445]: stty: stdin isn't a terminal
hayvalley[17445]: tset: standard error: Inappropriate ioctl for device
hayvalley[17445]: 
hayvalley[17445]: bash: line 23: exec: puma: not found
! Killing 'hayvalley' (17445)
* App 'hayvalley' shutdown and cleaned up
! Detecting app 'hayvalley' dying on start

Christian

@patrickwelker
Copy link

I'm in the same boat. Coming from POW and Just want to serve my static content… but nothing works in High Sierra… (should have expected this, but well, you got to update at some point).

With the Background LaunchAgent active I get: "unexpected exit"

My setup:

macOS 10.13.2
puma-dev: 0.11 (go1.9.1)
puma gem: 3.11.2

Wanting to avoid port problems I settled for Port 81 on a .test domain (sudo puma-dev --http-port 81 --https-port 443 -d dev:test:localhost => OSX High Sierra: can't listen on port 80 · Issue #138).

I added the gem and checked for it (despite it being inactive):

$ bundle exec puma

Puma starting in single mode...
* Version 3.11.2 (ruby 2.4.3-p205), codename: Love Song
* Min threads: 0, max threads: 16
* Environment: development
ERROR: No application configured, nothing to run

Results for tail:

$ tail -f ~/Library/Logs/puma-dev.log

mywebsite[97968]: bash: line 23: exec: puma: not found
! Killing 'mywebsite' (97968)
* App 'mywebsite' shutdown and cleaned up
! Detecting app 'mywebsite' dying on start
! Booting app 'mywebsite' on socket /Users/patte/.puma-dev/mywebsite/tmp/puma-dev-70819.sock
mywebsite[98220]: bash: no job control in this shell
mywebsite[98220]: bash: line 23: exec: puma: not found
! Killing 'mywebsite' (98220)
* App 'mywebsite' shutdown and cleaned up
! Detecting app 'mywebsite' dying on start

I even installed the puma gem and created a binstub just in case - but for static content this shouldn't matter. I also created a .powenv to be on the safe side.

Results for curl:

$curl -i -L --head http://mywebsite.test:81
HTTP/1.1 500 Internal Server Error
Date: Sun, 28 Jan 2018 18:20:48 GMT
Content-Length: 15
Content-Type: text/plain; charset=utf-8

Port 80 has something more to show:

$curl -i -L --head http://mywebsite.test
HTTP/1.1 200 OK
Date: Sun, 28 Jan 2018 18:21:06 GMT
Server: Apache/2.4.28 (Unix)
Content-Location: index.html.en
Vary: negotiate
TCN: choice
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
ETag: "2d-432a5e4a73a80"
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html

"Feature Request: Allow static files in public directory without rackup file · Issue #87" got my hopes up and I added a config.ru file, but it didn't work for me - I might have missed something here.

I get the same when deactivating the launch agent and using puma-dev -d test.

Maybe @evanphx can chime in and put some light on the static issue.

@jabr
Copy link

jabr commented Sep 18, 2018

I got static serving to work by adding a config.ru file with just this line:

run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, ['a']] }

The config.ru file goes in top-level directory, e.g.:

./testdomain/
./testdomain/public/
./testdomain/config.ru

@coreyward
Copy link

@jabr This just returns "a" instead of the website content inside public.

@jabr
Copy link

jabr commented Feb 28, 2019

It returns that when there is not a static file in public for the url. Basically a "404".

@coreyward
Copy link

coreyward commented Feb 28, 2019 via email

@stilist
Copy link

stilist commented Jul 13, 2019

Per the comments above, I'm successfully serving a site with just a public directory by adding a config.ru in the site folder's root with this content:

# @see https://github.com/puma/puma-dev/issues/140#issuecomment-422575346
run Proc.new { |env|
  [
    '200',
    { 'Content-Type' => 'text/html' },
    # @see https://github.com/puma/puma-dev/issues/140#issuecomment-468466432
    [File.read("public/index.html")]
  ]
}

I think this may be due to #102?

@nonrational
Copy link
Member

Closing as duplicate of #87

@momolog
Copy link

momolog commented Mar 8, 2020

@nonrational As of the description in the README this is not really a duplicate of #87

The README explicitly says:

Like pow, puma-dev support serving static files. If an app has a public directory, then any urls that match files within that directory are served. The static files have priority over the app.

So this should work at least with a config.ru rackup config file, files in public taking precedence.
And for the OP and others (including me) it is not, not even with a config.ru.

@nonrational
Copy link
Member

nonrational commented Mar 9, 2020

So this should work at least with a config.ru rackup config file, files in public taking precedence.

You are correct. puma-dev interrogates the path of the request, and if the file matches a file in a public directory, go will serve it directly, without involving puma. I've added tests to confirm static files are served with a config.ru.

Allowing puma-dev to serve static files without a config.ru file is the feature request represented in #87.

@momolog
Copy link

momolog commented Mar 10, 2020

@nonrational
I reproduced your test in https://github.com/puma/puma-dev/pull/234/files locally and it does work for a file public/greetings.txt
It does not, however, work for a file public/index.html - as strange as this may sound.

As I thought that this may also be a browser-related issue, I tested on Safari, Chrome and Firefox (on latest MacOSX), result is the same.

@nonrational
Copy link
Member

Well spotted @momolog !

https://golang.org/pkg/net/http/#ServeFile

As another special case, ServeFile redirects any request where r.URL.Path ends in "/index.html" to the same path, without the final "index.html". To avoid such redirects either modify the path or use ServeContent.

Gotta love Go. You have to handle setting req.Host = req.Header.get('Host') but it'll handle transparent redirects from index.html to /. 🤷‍♂

We can move to ServeContent to support /index.html.

@nonrational nonrational reopened this Mar 10, 2020
nonrational added a commit to nonrational/puma-dev that referenced this issue Mar 10, 2020
nonrational added a commit that referenced this issue Mar 19, 2020
* link in a static site with config.ru, ensure that public files are served

* s/Url/URL/g, better factoring of testAppsToLink

* clarify test names

* add failing tests

* lots of indexes

* whoops, consistent naming

* ensure that we don't expose more of the filesystem than we mean to

* avoid /index.html redirect by using ServeContent

#140 (comment)
@nonrational
Copy link
Member

this has now been addressed on master and will be released as part of 0.14 soon.

@nonrational nonrational added this to the v0.14 milestone Mar 19, 2020
@bradical
Copy link

bradical commented Jun 27, 2023

I'm on v0.17 and this is still happening. Without any config.ru, I'm not able to serve files from public. Is the problem with HTML specifically?

Getting the following with the directory structure below and local.host domain:

goodbye-28eda917[18916]: 2023-06-27 14:22:35 -0400 ERROR: No application configured, nothing to run
! Killing 'goodbye-28eda917' (18916) - 'stdout/stderr closed'
* App 'goodbye-28eda917' shutdown and cleaned up
! Detecting app 'goodbye-28eda917' dying on start
[~/Sites/goodbye]$ find .
./public
./public/index.html
./public/goodbye.txt
./tmp
./tmp/restart.txt

In browser when requesting: http://goodbye.local.host/index.html (same thing happens for .txt file)

unexpected exit:
	2023-06-27 14:25:31 -0400 ERROR: No application configured, nothing to run

This does work after adding a config.ru like the one mentioned #140 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants