Score:2

How do I start an nginx service using a custom nginx.conf file?

ky flag

I'm trying to set up a raspberry pi as a jellyfin media server.

I'd like to access the device over the internet from a domain I own.

I've followed the jellyfin instructions for setting up an nginx conf file. The instructions indicated I should create a new file in /etc/nginx/conf.d/jellyfin.conf. However, they don't indicate what I should do next. I assumed that nginx just sort of "knows" to look for custom conf files in its conf.d directory, but if I do sudo service nginx start, I'm not seeing the results I expect (a working reverse proxy). Then again, I'm also not really sure how to debug.

If I do sudo nginx -t I get

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

So, I guess that means that my custom conf file isn't getting picked up? But, if I try to do

nginx -t /etc/nginx/conf.d/jellyfin.conf 

I get an error:

nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/jellyfin.conf:2

Anyway, that's not necessarily what I want to do: I want nginx running as a service, because I also don't know how to quit out of SSH without closing a program I've started from the given terminal.

How can I make the nginx service pick up my custom conf file?

Michael Hampton avatar
cz flag
Why do you think it isn't reading your config file? You were exceptionally vague about this.
ky flag
Oh, well, I guess it's hard to say really! It's not working right, for one thing, but I'd love to know how to check for sure. I thought by doing `nginx -t /etc/nginx/conf.d/jellyfin.conf ` I was checking?
Michael Hampton avatar
cz flag
Run `nginx -T`. Every file that is used will be shown.
ky flag
I guess I'd like to confirm that nginx is even picking up on my conf file before I debug further why it isn't working.
ky flag
ah! Ok, it is picking up on it, never mind! # configuration file /etc/nginx/conf.d/jellyfin.conf:
Ivan Shatsky avatar
gr flag
@CalebJay Usually `*.conf` files from `/etc/nginx/conf.d` are included within the main `/etc/nginx/nginx.conf` configuration file under **http** context (look for the `include /etc/nginx/conf.d/*.conf;` line), they are not standalone configurations.
ky flag
I suppose I could change my question a bit to be "how do I tell if nginx is using my conf file?" Then Michael can add their answer, though I guess it'll be a duplicate at that point. Otherwise I suppose we should close it - I feel weird deleting it outright.
djdomi avatar
za flag
the answer is quite simple, in the main section where you placed the jelly file are only main items accepted but not server, this is due that there's also a site-enabled where server is allowed but not all main parts, you can see that if you look into nginx.conf for "include" and you will see the magic
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.