flat assembler
Message board for the users of flat assembler.

Index > Heap > [SOLVED] Requesting help with using Rwasa as a proxy.

Author
Thread Post new topic Reply to topic
anti-pasta



Joined: 30 Jul 2015
Posts: 8
anti-pasta
Hello,

I have been enjoying using RWASA after discovering it recently and have been exploring different ways that is can be configured. After many hours of trying, one method that I have not yet discovered how to configure RWASA has been to use it as a proxy using `-backpath`; or any other means. Specifically, I would like to use it as a proxy to a Ghost blog, which uses Node.js Ghost's github page is here:

-- https://github.com/TryGhost/Ghost

I am using Debian 8.1 and on my server I have left the default Ghost configuration to listen on 127.0.0.1:2368, only changing the url to: `http://www.frijoles.space`. I own the domain and am sure that it is resolving correctly. The stock default configuration file can be found here:

-- https://github.com/TryGhost/Ghost/blob/master/config.example.js

The RWASA command/configuration that I am using is:

strace ./rwasa -bind 80 -backpath 127.0.0.1:2368

When using logging, I was unable to see any output at all; most likely a mistake of my own:

strace ./rwasa -bind 80 -backpath 127.0.0.1:2368 -logpath /var/log/rwasa -errsyslog

### Output from Node Package Manager while attempting to use RWASA as a proxy to Node.js/Ghost:

npm start --production

> ghost@0.6.4 start /var/www/ghost
> node index

Migrations: Up to date at version 003
Ghost is running...
Your blog is now available on http://www.frijoles.space
Ctrl+C to shut down
my.pub.ip.addr - - [30/Jul/2015:13:47:02 +0000] "GET / HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"

Since my public IP address gets listed, rather than 127.0.0.1, it appears that nothing gets proxied, or not as intended, despite node.js echoing headers from the request. It seems that my initial connection to RWASA gets made and then drops off when it is supposed to be handed off to localhost, where ghost is listening, resulting in a 502 error. Here is a strace:

=======================================================================

strace ./rwasa -bind 80 -backpath 127.0.0.1:2368
execve("./rwasa", ["./rwasa", "-bind", "80", "-backpath", "127.0.0.1:2368"], [/* 16 vars */]) = 0
mmap(NULL, 17179869184, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 1073741824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe65e936000
mremap(0x7fe65e936000, 1073741824, 139272, 0) = 0x7fe65e936000
mremap(0x7fe65e936000, 139272, 143368, 0) = 0x7fe65e936000
mremap(0x7fe65e936000, 143368, 151560, 0) = 0x7fe65e936000
open("/proc/self/auxv", O_RDONLY) = 3
read(3, "!\0\0\0\0\0\0\0\0\20\2735\377\177\0\0\20\0\0\0\0\0\0\0u\213\211\37\0\0\0\0"..., 1024) = 304
close(3) = 0
getpid() = 3729
socket(PF_LOCAL, SOCK_DGRAM, 0) = 3
connect(3, {sa_family=AF_LOCAL, sun_path="/dev/log"}, 110) = 0
mremap(0x7fe65e936000, 151560, 172040, 0) = 0x7fe65e936000
gettimeofday({1438269421, 788685}, NULL) = 0
open("/dev/urandom", O_RDONLY) = 4
read(4, "W\335\254\220\353\336Hy\373\206\324\n0_\333\364\356-l\336\267\242C\244>\325\32\375a\244a\376", 32) = 32
close(4) = 0
gettimeofday({1438269421, 789065}, NULL) = 0
mremap(0x7fe65e936000, 172040, 184328, 0) = 0x7fe65e936000
rt_sigaction(SIGPIPE, {SIG_IGN, [PIPE], SA_RESTORER|SA_RESTART, 0x434600}, NULL, Cool = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=64*1024, rlim_max=64*1024}) = 0
setrlimit(RLIMIT_NOFILE, {rlim_cur=64*1024, rlim_max=64*1024}) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=64*1024, rlim_max=64*1024}) = 0
epoll_create(65535) = 4
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
gettimeofday({1438269421, 789916}, NULL) = 0
mremap(0x7fe65e936000, 184328, 225288, 0) = 0x7fe65e936000
mremap(0x7fe65e936000, 225288, 765960, 0) = 0x7fe65e936000
gettimeofday({1438269421, 791118}, NULL) = 0
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=123, ...}) = 0
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=123, ...}) = 0
open("/etc/resolv.conf", O_RDONLY) = 5
read(5, "domain members.linode.com\nsearch"..., 123) = 123
close(5) = 0
mremap(0x7fe65e936000, 765960, 798728, 0) = 0x7fe65e936000
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5
ioctl(5, FIONBIO, [1]) = 0
connect(5, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("75.127.97.6")}, 16) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 5, {EPOLLIN, {u32=1586900816, u64=140627406106448}}) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
ioctl(6, FIONBIO, [1]) = 0
connect(6, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("75.127.97.7")}, 16) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 6, {EPOLLIN, {u32=1586900624, u64=140627406106256}}) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7
ioctl(7, FIONBIO, [1]) = 0
connect(7, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("45.56.113.178")}, 16) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 7, {EPOLLIN, {u32=1586900432, u64=140627406106064}}) = 0
gettimeofday({1438269421, 793138}, NULL) = 0
mremap(0x7fe65e936000, 798728, 946184, 0) = 0x7fe65e936000
mremap(0x7fe65e936000, 946184, 950280, 0) = 0x7fe65e936000
gettimeofday({1438269421, 793531}, NULL) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 8
setsockopt(8, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(8, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
listen(8, 512) = 0
setsockopt(8, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
setsockopt(8, SOL_TCP, TCP_NODELAY, [1], 4) = 0
ioctl(8, FIONBIO, [1]) = 0
mremap(0x7fe65e936000, 950280, 954376, 0) = 0x7fe65e936000
stat("/etc/passwd", {st_mode=S_IFREG|0644, st_size=1485, ...}) = 0
mremap(0x7fe65e936000, 954376, 1089544, 0) = 0x7fe65e936000
open("/etc/passwd", O_RDONLY) = 9
read(9, "root:x:0:0:root:/root:/bin/bash\n"..., 1485) = 1485
close(9) = 0
mremap(0x7fe65e936000, 1089544, 1105928, 0) = 0x7fe65e936000
mremap(0x7fe65e936000, 1105928, 1130504, 0) = 0x7fe65e936000
setgid(65534) = 0
setuid(65534) = 0
fork() = 3730
_exit(0) = ?
+++ exited with 0 +++

======================================================================

When I curl for 127.0.0.1:2368 (from the server that ghost is running on) everything seems to be ok:

curl -I 127.0.0.1:2368
HTTP/1.1 200 OK
X-Powered-By: Express
Cache-Control: public, max-age=0
Content-Type: text/html; charset=utf-8
Content-Length: 4252
ETag: W/"woGYVbC6nlnR2B5lm6e1ng=="
Vary: Accept-Encoding
Date: Thu, 30 Jul 2015 19:04:46 GMT
Connection: keep-alive

And from remote, on the public interface, things seem ok too (love the reference to HeavyThing Smile ):

curl -I frijoles.space
HTTP/1.1 200 OK
X-Powered-By: Express
Cache-Control: public, max-age=0
Content-Type: text/html; charset=utf-8
Content-Length: 4252
ETag: W/"woGYVbC6nlnR2B5lm6e1ng=="
Vary: Accept-Encoding
Date: Thu, 30 Jul 2015 19:05:48 GMT
Connection: keep-alive
Server: HeavyThing

Here is the big tease, I can even remotely curl for the webpage too:

curl -L frijoles.space
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<title>Ghost</title>
<meta name="description" content="Just a blogging platform." />

<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="shortcut icon" href="/favicon.ico">

<link rel="stylesheet" type="text/css" href="/assets/css/screen.css?v=a399d0745e" />
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400" />

<link rel="canonical" href="http://www.frijoles.space/" />

<meta property="og:site_name" content="Ghost" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Ghost" />
<meta property="og:description" content="Just a blogging platform." />
<meta property="og:url" content="http://www.frijoles.space/" />

<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Ghost" />
<meta name="twitter:description" content="Just a blogging platform." />
<meta name="twitter:url" content="http://www.frijoles.space/" />

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Website",
"publisher": "Ghost",
"url": "http://www.frijoles.space/",
"description": "Just a blogging platform."
}
</script>

<meta name="generator" content="Ghost 0.6" />
<link rel="alternate" type="application/rss+xml" title="Ghost" href="http://www.frijoles.space/rss/" />
</head>
<body class="home-template nav-closed">

<div class="nav">
<h3 class="nav-title">Menu</h3>
<a href="#" class="nav-close">
<span class="hidden">Close</span>
</a>
<ul>
<li class="nav-home nav-current" role="presentation"><a href="http://www.frijoles.space/">Home</a></li>
</ul>
<a class="subscribe-button icon-feed" href="http://www.frijoles.space/rss/">Subscribe</a>
</div>
<span class="nav-cover"></span>


<div class="site-wrapper">


<header class="main-header no-cover">
<nav class="main-nav overlay clearfix">

<a class="menu-button icon-menu" href="#"><span class="word">Menu</span></a>
</nav>
<div class="vertical">
<div class="main-header-content inner">
<h1 class="page-title">Ghost</h1>
<h2 class="page-description">Just a blogging platform.</h2>
</div>
</div>
<a class="scroll-down icon-arrow-left" href="#content" data-offset="-45"><span class="hidden">Scroll Down</span></a>
</header>

<main id="content" class="content" role="main">

<div class="extra-pagination inner">
<nav class="pagination" role="navigation">
<span class="page-number">Page 1 of 1</span>
</nav>
</div>

<article class="post tag-getting-started">
<header class="post-header">
<h2 class="post-title"><a href="/welcome-to-ghost/">Welcome to Ghost</a></h2>
</header>
<section class="post-excerpt">
<p>You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your content by <a class="read-more" href="/welcome-to-ghost/">&raquo;</a></p>
</section>
<footer class="post-meta">

<a href="/author/ghost-owner/">Ghost Owner</a>
on <a href="/tag/getting-started/">Getting Started</a>
<time class="post-date" datetime="2015-07-30">30 July 2015</time>
</footer>
</article>

<nav class="pagination" role="navigation">
<span class="page-number">Page 1 of 1</span>
</nav>

</main>


<footer class="site-footer clearfix">
<section class="copyright"><a href="http://www.frijoles.space">Ghost</a> &copy; 2015</section>
<section class="poweredby">Proudly published with <a href="https://ghost.org">Ghost</a></section>
</footer>

</div>

<script src="/public/jquery.min.js?v=a399d0745e"></script>

<script type="text/javascript" src="/assets/js/jquery.fitvids.js?v=a399d0745e"></script>
<script type="text/javascript" src="/assets/js/index.js?v=a399d0745e"></script>

</body>
</html>


The page simply will not load in my browser.

======================================================================

Just to rule out other possible problems, I configured an NGINX server to proxy over to Ghost, on localhost:2368. This was successful and is exactly what I would like to achieve, only with RWASA instead.


###NGINX vhost config:

server {
listen 80;
server_name frijoles.space;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368/;
}
}


### Output from Node Package Manager with NGINX running as a proxy to Node.js/Ghost:

npm start --production

> ghost@0.6.4 start /var/www/ghost
> node index

Migrations: Up to date at version 003
Ghost is running...
Your blog is now available on http://www.frijoles.space
Ctrl+C to shut down
127.0.0.1 - - [30/Jul/2015:13:30:53 +0000] "GET / HTTP/1.0" 200 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"
127.0.0.1 - - [30/Jul/2015:13:30:53 +0000] "GET /assets/css/screen.css?v=03341c80f8 HTTP/1.0" 200 - "http://www.frijoles.space/" "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"
127.0.0.1 - - [30/Jul/2015:13:30:53 +0000] "GET /assets/js/jquery.fitvids.js?v=03341c80f8 HTTP/1.0" 200 - "http://www.frijoles.space/" "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"
127.0.0.1 - - [30/Jul/2015:13:30:53 +0000] "GET /assets/js/index.js?v=03341c80f8 HTTP/1.0" 200 - "http://www.frijoles.space/" "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"
127.0.0.1 - - [30/Jul/2015:13:30:53 +0000] "GET /public/jquery.min.js?v=03341c80f8 HTTP/1.0" 200 - "http://www.frijoles.space/" "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"
127.0.0.1 - - [30/Jul/2015:13:30:53 +0000] "GET /assets/fonts/casper-icons.woff?v=1 HTTP/1.0" 200 2580 "http://www.frijoles.space/assets/css/screen.css?v=03341c80f8" "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"

=======================================================================

After trying this with RWASA and browsing for the website, my browser tab's indicator wheel keeps 'spinning' rather than immediately throwing an error. Unfortunately, it eventually 'gives up', resulting in the 502 after some time.

I am almost certain that my syntax is incorrect, since, I was able to get NGINX to proxy as intended. I am just unsure of what I am doing wrong regarding RWASA. If anyone has any ideas, I would be very grateful for you help.


Last edited by anti-pasta on 06 Dec 2015, 07:19; edited 1 time in total
Post 30 Jul 2015, 19:16
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 357
Location: Australia
redsock
Author of rwasa here, will review and let you know, thanks for the headsup!
Post 30 Jul 2015, 20:45
View user's profile Send private message Reply with quote
anti-pasta



Joined: 30 Jul 2015
Posts: 8
anti-pasta
Whoa! The best person on the planet to help with this, thank you for looking into the issue. Another thing that I may have overlooked might be a privileges issue. It seems unlikely to me because in my testing I have been running everything as root. Although the directory `/var/www` had belonged to user 'ghost', I recently chowned everything within it back to root. This made no difference. Currently, I have npm running in a screen session and everything is live, like listed above, for further analysis from the community. Thanks once again redsock!
Post 30 Jul 2015, 21:55
View user's profile Send private message Reply with quote
anti-pasta



Joined: 30 Jul 2015
Posts: 8
anti-pasta
Hi,

I thought that I would follow up with everyone. I tried a new experiment using two instances of RWASA, one running on 127.0.0.1:4050 and another running on frijoles.space:8040. The results were precisely what I was expecting:

./rwasa -bind 127.0.0.1:4050 -sandbox /var/www/test

./rwasa -bind 8040 -backpath 127.0.0.1:4050

The results:
curl -I localhost:4050
HTTP/1.1 200 She'll be apples ## <-- LOL I love the Easter-eggs!
Content-Type: text/html
Cache-Control: no-transform,public,max-age=300
Last-Modified: Mon, 10 Aug 2015 22:50:40 GMT
ETag: "UTsRfw2ZAIqU7VjC0gbpVdgqPOUO+L4E17+p"
Connection: keep-alive
Server: HeavyThing
Date: Tue, 11 Aug 2015 07:14:47 GMT
Content-Length: 27

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

curl -L localhost:4050
This is a local host test.

======================================================================

curl -I frijoles.space:8040
HTTP/1.1 200 She'll be apples
Content-Type: text/html
Cache-Control: no-transform,public,max-age=300
Last-Modified: Mon, 10 Aug 2015 22:50:40 GMT
ETag: "UTsRfw2ZAIqU7VjC0gbpVdgqPOUO+L4E17+p"
Connection: keep-alive
Server: HeavyThing
Date: Tue, 11 Aug 2015 07:29:38 GMT
Content-Length: 27

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

curl -L http://www.frijoles.space:8040
This is a local host test.

BINGO!! Proxys just fine in this configuration.

This is Just a quick test/update on some progress that I have made with this. Still seems there is some issues with the way the -backpath talks to node.
Post 11 Aug 2015, 07:26
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 357
Location: Australia
redsock
Quick update: Been busy doing client (read: paying) work Smile Haven't forgot about you though and will advise once I figure this out. I got another outstanding one the other day with nonstandard backends so will deal with both at the same time. Cheers!
Post 15 Aug 2015, 08:01
View user's profile Send private message Reply with quote
anti-pasta



Joined: 30 Jul 2015
Posts: 8
anti-pasta
Thank you for the update, I understand. I got a bit excited is all, this is some very cool software!

Regards
Post 16 Aug 2015, 01:30
View user's profile Send private message Reply with quote
A010



Joined: 15 Aug 2015
Posts: 1
A010
I'm sorry to hijack the thread, but I wonder can rwasa run on *BSD?

Thanks.
Post 16 Aug 2015, 15:35
View user's profile Send private message Reply with quote
PeExecutable



Joined: 26 Jun 2015
Posts: 181
PeExecutable
What is rwasa all about?
Post 17 Aug 2015, 21:21
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 357
Location: Australia
redsock
PeExecutable wrote:
What is rwasa all about?
My fasm Linux x86_64 webserver: https://2ton.com.au/rwasa/
A010 wrote:
...can rwasa run on *BSD?
AFAIK, even the *BSD ability to run some linux binaries doesn't include epoll syscall support, so I'd doubt it would run happily under BSD variants.

Been super busy with client work, will be attending to the backend issue hopefully this coming weekend on my off time.

Cheers!
Post 18 Aug 2015, 20:47
View user's profile Send private message Reply with quote
anti-pasta



Joined: 30 Jul 2015
Posts: 8
anti-pasta
@A010:

You may be able to make use of freeBSD's use of Branding for the ELF binary format. Under BSD, you should be able to see if support for Linux software is enabled in the kernel by running 'kldstat' in your terminal. I am not very knowledgeable about this, but do know that to some extent, it is possible to run software that was made for Linux on BSD variants. Check out the following for more info:

-- http://www.onlamp.com/pub/a/bsd/2000/03/17/linuxapps.html

RWASA itself appears to be an executable binary file. Assuming that not much more is required in the way of dependencies or other external factors, you may be able to get it to run in BSD. At least, there is no hurt in trying to get it running. There are some pretty clear instructions in the link that redsock posted previously for getting a basic website up.

regards
Post 16 Sep 2015, 14:59
View user's profile Send private message Reply with quote
anti-pasta



Joined: 30 Jul 2015
Posts: 8
anti-pasta
I spoke too soon.
Post 06 Dec 2015, 07:17
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.