Need help modifying hosts file using batch file - hosts

I know how to modify a hosts file using batch*, but is there a way to add a comment above the entry?
*echo 0.0.0.0 website.com
i.e.
#New website IP
0.0.0.0 website.com

try nano hosts to edit the file with a proper text editor

Related

Mosquitto dynamic security does not allow to insert clients or roles

Hi everyone I've been trying to use mosquitto dynamic security plugin, the broker is running in a docker container, and so far everything seems to work as expected I can generate de file dynamic-secutiry.json for that I used the following command mosquitto_ctrl dynsec init path/to/dynamic-security.json user and after that, I set the password as user, so managed to open the file and make sure that it was created right, and indeed it was. However, when I try to modify the file like adding a new client for instance I got the following message Connection error: Not authorized in order to add new clients I've been something like this mosquitto_ctrl -u user -P user dynsec createRole rolepizza and then I'm getting this:
That's the dynamic-security.json
Finally my mosquitto.conf
I've been following this tutorials:
https://www.youtube.com/watch?v=QvRBtRH2mN0
http://www.steves-internet-guide.com/understanding-mosquitto-dynamic-security-plugin/
I'd appreciate it if someone could tell me what I've been doing wrong. Thanks in advance
As hashed out in the comments, the problem was most likely a lack of write permissions on dynamic-security.json file due to creating it as root.
Mosquitto will normally drop root permissions on startup, so all config/log files should be writable by a none privileged user (you can set the user in the mosquitto.conf file.

How can i access the GeoLite database in nginx?

I run a Nginx proxy and want to use the GeoLite2-Country/city databases.
I followed the instructions on
"https://docs.nginx.com/nginx/admin-guide/dynamic-modules/geoip2/"
and "https://github.com/leev/ngx_http_geoip2_module".
So I have the required Nginx-module. Also I installed Libmaxminddb.
When I want to build my Docker-File I get this error:
"MMDB_open("/geoip/GeoLite2-City.mmdb") failed - Error opening the
specified MaxMind DB file in /etc/nginx/nginx.conf:17"
In the command window I can access to the Mmdb via
$ mmdblookup --file /etc/nginx/geoip/GeoIP/GeoIP2-Country.mmdb --ip 8.8.8.8
source: "https://github.com/leev/ngx_http_geoip2_module"
So the file should be accessible.. (the path is different because the nginx.conf path starts at etc/nginx.
Maybe anyone have some idea I can try or faced the same problem?
Thank you and best regards from earth!
UPDATE:
I am using "Alpine 3.13.5" && "Nginx-1.21.0"
The path in Nginx.conf needed to be a full path! Otherwise than the loaded module.

Adding additional host to Juypterhub DockerSpawner

I am using Jupyterhub 0.9.4 with DockerSpawner.
My goal is to pass every container spawned by the Spawner an additional host name, so make an additional entry in /etc/hosts.
I first tried via my docker-compose.yml file, which does not work, as the container are created by Jupyterhub.
I also tried it in the Dockerfile itself, but there it got overwritten.
I further tried it with changes in the jupyterhub_config.py file, by adding:
c.DockerSpawner.extra_create_kwargs.update({'command': '--add-host="<ip-address> <hostname>"'})
Still I do not see an entry in the /etc/hosts file in the container.
Anyone has a clue where I have to add it?
Thanks,
Max
You can do the equivalent of docker run --add-host "foo.domain.local:192.168.1.12" ... like so:
c.DockerSpawner.extra_host_config.update({
"extra_hosts": {
"foo.domain.local":"192.168.1.12",
"other.domain.local":"192.168.1.13"
}
})
I couldn't find that in any documentation.

Nextcloud trusted domain with auto configuration via environment variables

When i'm configure nextcloud (which run in docker container ) using environment variables , i can't visit site after it and i need to configure manually with connection to docker with bash .
How to solve this problem or make it automatically without creating my own docker image?
The environment variable only gets picked up and applied to the config when building a brand new instance. If you've already created a config.php file which is mapped in that volume, that environment variable will not override it.
If you want to keep your existing config intact, you need to SSH into your NAS and go to your Nextcloud Docker folder and find /config/config.php. For me this was located at: /docker/nextcloud/config/www/nextcloud/config
Then type: sudo nano config.php
Quick vi refresher - i to insert, esc to exit edit mode, and :qw to quit write mode but in this instance you may need to use :qw!
And add a new domain just add new entries by appending a new item to the PHP array:
'trusted_domains' =>
array (
0 => '192.168.0.29',
1 => 'cloud.example.com',
),
Reference: https://help.nextcloud.com/t/howto-add-a-new-trusted-domain/26
That sounds like an issue with Trusted Domains.
If you have a look at their repository (readme) at https://github.com/nextcloud/docker you will see an environment variabled called NEXTCLOUD_TRUSTED_DOMAINS which you can set in your docker environment.
Alternatively, you will find it in the {app}/config/config.php
The default values set for it, in my experience, is only 'localhost' to enable connecting to NextCloud from localhost at the very least.
Hope this helps.

unable to start rabbitmq-server

I installed rabbitmq using homebrew. I am trying to start rabbitmq server but I always get this error which I am unable to figure out why!
I have erlang installed and there is no other application running on the same port.
$ rabbitmq-server
{error_logger,{{2013,2,11},{22,37,49}},"Can't set short node name!\nPlease check your configuration\n",[]}
{error_logger,{{2013,2,11},{22,37,49}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,320}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}},{ancestors,[net_sup,kernel_sup,]},{messages,[]},{links,[]},{dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,24},{reductions,249}],[]]}
{error_logger,{{2013,2,11},{22,37,49}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs,{net_kernel,start_link,[[rabbitmqprelaunch1593,shortnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,{{2013,2,11},{22,37,49}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,undefined},{name,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]}
{error_logger,{{2013,2,11},{22,37,49}},std_info,[{application,kernel},{exited,{shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}"}
Crash dump was written to: erl_crash.dump
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}})
btw, erl -sname abc gives the same output
Update:
This is what I have in /etc/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
check your computer name and your short host name or alias name in /etc/hosts, match this
Check your computer name [wendy#nyc123]$
nyc123 is your computer name
Check your short hostname
[wendy#nyc123]$ hostname -s
[wendy#nyc123]$ nyc456
This error could happen because your computer name and short host name didn't match. To match this, you can change the computer hostname or alias name.
Change computer host name
[wendy#nyc123]$ hostname nyc456
close your terminal and open again
[wendy#nyc456]$
the computer name has changed
or
Change alias name in /etc/hosts
127.0.0.1 nyc123.com nyc123
save and check again
[wendy#nyc123]$ hostname -s
[wendy#nyc123]$ nyc123
Restart your rabbitmq!
[root#nyc123]$ rabbitmq-server start</p>
RabbitMQ 3.6.0. Copyright (C) 2007-2015 Pivotal Software, Inc.</p>
## ## Licensed under the MPL. See http://www.rabbitmq.com/</p>
## ##</p>
########## Logs: /var/log/rabbitmq/rabbitmq#nyc123.com.log</p>
###### ## /var/log/rabbitmq/rabbitmq#nyc123.com-sasl.log</p>
##########</p>
Starting broker... completed with 6 plugins.</p>
I looked for a similar error on google, and it looks like it can happen if your /etc/hosts file is in the wrong format. Try fixing it and see if that helps.
References:
http://www.ejabberd.im/node/18
Explanation on RabbitMQ Mailing list
Edit: For completeness, it seems like setting a long name (of the form abc#abc) worked.
Found the answer here:
control rabbitmq 'name' not 'sname'
Set your machine name to something simple and make it an alias to locahost
I also encountered this problem yesterday and found the root cause:
I had changed my system's hostname to a "long" name, pm3(hc desktop).
If your server's hostname is long or invalid, Linux can still work and no error message is prompted to you. As you just modify the /etc/hostname file and reboot. However, the rabbitmq server may not work and give this "short-name" error message to you.
I changed hostname back to "pm3", rebooted and everything went well.
I solved this issue changing the computer name (on windows 8.1). The problem was that the name had a strange character (é) spanish letter. My computer name was Andrés and I changed it to Andres, restarted my computer and everything worked well. I think that Rabbit could not recognize that name (Andrés) for that strange character.
remove old style config file /etc/rabbitmq/rabbitmq.config
and use rabbitmq.conf
with listeners.tcp.default = 5672
after that restart rabbitmq server again
In my case that solved the issue in ec2 instance

Resources