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

Not creating another domain. #3

Open
jackkelly-bayliss opened this issue Oct 17, 2017 · 8 comments
Open

Not creating another domain. #3

jackkelly-bayliss opened this issue Oct 17, 2017 · 8 comments

Comments

@jackkelly-bayliss
Copy link

Hello,

I am currently having the issue where it will not detect a new domain name. It's only reading the very first line of proxydomains. Any suggestions to resolve this?

if nshield_proxy is 1 and dryrun is 0:
	print "Setting up nShield proxy for domains found in /etc/nshield/proxydomains\n"
        # Generates nginx proxy_pass from /etc/nshield/proxydomains and checks if already present in nginx conf
        with open("/etc/nshield/proxydomains") as f:
                content = f.readlines()
                content1 = content[0].split(' ')
                ip = content1[1].strip('\n')
                domain = content1[0]
                if domain not in os.popen("cat /etc/nginx/sites-enabled/dynamic-vhost.conf").read():
                    print "I Will generate proxy configuration for site "+domain+" on IP: "+ip
                    os.popen("""echo 'server {
        listen 80;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name """+domain+""";

        location / {
    proxy_pass       http://"""+ip+""";
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;
}
}
' >> /etc/nginx/sites-enabled/dynamic-vhost.conf""")
                    os.popen('service nginx restart')
                else:
                    print "Domain already configured"

        print "Now you can test that your site is reachable via nShield proxy by changing the domain DNS or via your PC hosts file or directly DNS A record"

Kind Regards,
Jack K-B

@fnzv
Copy link
Owner

fnzv commented Oct 18, 2017

Hello Jack,
I fixed the code and now the proxydomain configuration is working with multiple domains

commit link

Sami

@fnzv fnzv added the bug label Oct 18, 2017
@jackkelly-bayliss
Copy link
Author

Hello Sami,

That's perfect, thank you very much for resolving this issue for me!

Kind Regards,
Jack K-B

@jackkelly-bayliss
Copy link
Author

Hello,

I'm sorry for re-opening this issue but upon executing the 'python nshield-main.py' command, I'm receiving this error http://prntscr.com/gz44pn - The file does exist and I've checked it's in the correct path.

Kind Regards,
Jack K-B

@fnzv
Copy link
Owner

fnzv commented Oct 24, 2017

Hello,
The error is most likely from the variable not a str, now i have added the str() conversion

@jackkelly-bayliss
Copy link
Author

Hello,

That's perfect thank you. I've just executed git pull and it's now showing the error http://prntscr.com/h2bv4k

Kind Regards,
Jack K-B

@fnzv
Copy link
Owner

fnzv commented Oct 29, 2017

Hello,
Could you remove the /home/nShield/ folder and run again:
cd /home/ && git clone https://github.com/fnzv/nShield.git && bash nShield/install.sh
?
From my ubuntu 16 image works without issues

@jackkelly-bayliss
Copy link
Author

Hello,

Thank you for replying. I've done as you said and it ran without issues upon default settings. As soon as I turned the variable 'nshield_proxy' to '1'. It's showing the same error as the above.

The machine that I'm receiving this error on is 'Ubuntu 16.04.3 LTS'.

Kind Regards,
Jack K-B.

@fnzv
Copy link
Owner

fnzv commented Nov 3, 2017

Hello,
Sorry for the late reply, here is the fix: commit 5af9a02eb63a00f18ec25cc98de4b8f5ff0ef611

Be sure there are no other blank lines on the /etc/nshield/proxydomains file.. example:

root@ubuntu16:/home# cat /etc/nshield/proxydomains
test1.com 123.123.123.123
test2.com 123.123.123.123
test3.com 123.123.123.123
test4.com 123.123.123.123
root@ubuntu16:/home#

@fnzv fnzv added the solved label Dec 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants