# Socket address relative to prefix

**URL:** <https://www.ruby-forum.com/t/socket-address-relative-to-prefix/198401>\
**Category:** NGINX\
**Created:** [October 31, 2010, 7:22pm UTC](https://www.ruby-forum.com/t/socket-address-relative-to-prefix/198401 "2010-10-31T19:22:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [October 31, 2010, 7:22pm UTC](https://www.ruby-forum.com/t/socket-address-relative-to-prefix/198401/1 "2010-10-31T19:22:21Z")

</div>

Hi there.

I’m using nginx (v0.8.53 on Arch Linux) for web application development  
and testing, and I’ve encountered a problem. I’ll specify the problem  
first and then explain why I ran into it.

Problem:  
Is there a way to specify a unix socket address (as in “fcgi\_pass  
unix:/path/to/socket”) relative to nginx prefix? I’ve tried using  
“fcgi\_pass: unix:relative/path”, but nginx still interpreted it as  
absolute path (is this a bug?).

Rationale:  
I’d like to be able to specify socket address relative to prefix because  
of the setup I use - I run nginx (as well as php fastcgi) as  
non-privileged user and keep all the relevant files inside my home dir.  
This is mainly for convenience, so that I don’t have to go root  
everytime I want to tweak some settings or start and stop servers. I use  
only relative paths in nginx.conf, and start nginx with a wrapper script  
that sets nginx prefix to the directory it resides in. That way I don’t  
have to update config files everytime I move (or copy) this directory.

Any suggestions?

Regards,  
Radek

Posted at Nginx Forum:

> **[Socket address relative to prefix](https://forum.nginx.org/read.php?2,146304,146304#msg-146304)**
>
> Hi there. I'm using nginx (v0.8.53 on Arch Linux) for web application development and testing, and I've encountered a problem. I'll specify the problem first and then explain why I ran into it. Problem: Is there a way to specify a unix socket address...

---

<div class="post-metadata">

**Author:** ![Rad3k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Rad3k](https://www.ruby-forum.com/u/Rad3k)\
**Post date:** [January 15, 2013, 12:33am UTC](https://www.ruby-forum.com/t/socket-address-relative-to-prefix/198401/2 "2013-01-15T00:33:15Z")

</div>

I know this as posted ages ago however its the number 1 post in google  
and  
has no answer.

NGINX uses a path relative to where it was started from when it comes to  
reading sockets at least. I am unsure if this affects additional  
functionality.

At first I thought it was reading from the compile prefix but this  
doesnt  
seem to be the case and I also dont see any documentation on this.

Here is an example.

Starting NGINX manually from the NGINX folder  
cd ~/nginx; sbin/nginx

Now all SOCKET paths are relative to ~/nginx

However;  
cd ~; nginx/sbin/nginx

SOCKET paths are now relative to ~

Just figured I would help document.

Posted at Nginx Forum:

> **[Re: Socket address relative to prefix](https://forum.nginx.org/read.php?2,146304,235097#msg-235097)**
>
> Hi there. I'm using nginx (v0.8.53 on Arch Linux) for web application development and testing, and I've encountered a problem. I'll specify the problem first and then explain why I ran into it. Problem: Is there a way to specify a unix socket address...

---

<div class="post-metadata">

**Author:** ![Rad3k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Rad3k](https://www.ruby-forum.com/u/Rad3k)\
**Post date:** [January 15, 2013, 7:31pm UTC](https://www.ruby-forum.com/t/socket-address-relative-to-prefix/198401/3 "2013-01-15T19:31:32Z")

</div>

Thanks for answering 🙂

By the way, excellent timing - I have just returned, after long break,  
to  
experiments with web development, so I’ll definitely make use of this  
knowledge.

Back then I worked around this problem by preprocessing config files  
each  
time the service was started, and I’ll probably still have to to this  
for  
php and mysql. But it’s nice that I won’t need it for Nginx anymore.

Posted at Nginx Forum:

> **[Re: Socket address relative to prefix](https://forum.nginx.org/read.php?2,146304,235152#msg-235152)**
>
> Hi there. I'm using nginx (v0.8.53 on Arch Linux) for web application development and testing, and I've encountered a problem. I'll specify the problem first and then explain why I ran into it. Problem: Is there a way to specify a unix socket address...
