LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-20-2017, 09:28 PM   #1
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 282

Rep: Reputation: 30
Switching index's in Nginx via Bash


So let me just say I'm not a programmer nor am I elegant in any way. I'm a brute force kind of guy. Basically I'm pinging a website to get the ip it is using as it switches between 2. Once I have it I have a bash script that compares it to what I'm expecting and if it matches 1 ip address it moves index file 1 into the /var/www/html directory. If it matches the other it moves index file 2 into it. Right now I'm getting a 403 error. I'm messing around with the nginx.conf file to fix this but there's got to be a better way right?
 
Old 08-21-2017, 01:56 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Right now I'm getting a 403 error. I'm messing around with the nginx.conf file to fix this but there's got to be a better way right?
Take a look at the nginx logs for the 403 (Forbidden) error.
Could be a permissions issue, so make sure the file has 644 attributes and the directory /var/www/html (and those above it) 755.

Regards
 
Old 08-24-2017, 07:31 PM   #3
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 282

Original Poster
Rep: Reputation: 30
My boss decided it wasn't worth the effort apparently. I'll try to make it work on my own time. Thanks!
 
Old 08-30-2017, 11:55 AM   #4
Quarind
LQ Newbie
 
Registered: Aug 2017
Posts: 7

Rep: Reputation: Disabled
If your nginx web-server runs by user nginx or www-data, files in wwwroot need to be with nginx or www-data user permissions.
If your bash script copy files into wwwroot by root (for example), you need set permissions for wwwroot like:
Code:
chown -r www-data:www-data /var/www/html/
 
  


Reply

Tags
nginx



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Nginx as SSL Proxy for Weblogic Server and switching ports. mosiac Linux - Desktop 5 07-24-2013 09:57 AM
Nginx + Apache. Always get /var/www/html/index.html angryrabbit Linux - Server 1 11-27-2011 04:56 PM
get index of an element in array in bash mangatmodi Programming 4 11-20-2009 07:45 AM
Bash Script Array index value Kedelfor Programming 10 04-29-2009 04:37 AM
two-dimensional array in C: switching between pointer and index notation frankie_DJ Programming 3 02-22-2007 11:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration