AWS EB extending nginx locations; not accepted - amazon-web-services

so i am trying to add custom location rules to the standard Elastic Beanstalk nginx config.
As i have found out, i need to add "anyname.conf" to .platform/nginx/conf.d/elasticbeanstalk, but it just throws the Error when creating the environment:
2022/03/10 12:41:04.669263 [ERROR] An error occurred during execution of command [app-deploy] - [start proxy with new configuration]. Stop running the command. Error: copy proxy conf from staging failed with error validate nginx configuration failed with error Command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf failed with error exit status 1. Stderr:nginx: [emerg] "limit_except" directive is not allowed here in /var/proxy/staging/nginx/conf.d/elasticbeanstalk/5xx.conf:1
nginx: configuration file /var/proxy/staging/nginx/nginx.conf test failed
My .conf file has just this one line:
limit_except GET HEAD POST { deny all; }
Is the .conf file missing something?
Maybe also important:
There is also a custom .conf in nginx/conf.d/ already, but not for locations. No problems with that one

Related

Solana Anchor framework: Can't connect to localhost and therefor not deply to it

Anchor deploy
Deploying workspace: http://localhost:8899
Upgrade authority: /home/tomcatzy/.config/solana/id.json
Deploying program "basic-1"...
Program path: /home/tomcatzy/projects/anchor/examples/tutorial/basic-1/target/deploy/basic_1.so...
Error: RPC request error: cluster version query failed: error sending request for url (http://localhost:8899/): error trying to connect: tcp connect error: Connection refused (os error 111)
There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.
solana config set --url http://localhost:8899 (Is this enough to start the localhost ?)
solana-keygen new
solana-test-validator
It seems strange that after a succesful anchor build that i can't do a anchor deploy with the solana command lines ran above.
If by any means 'need' to run a - npm init - then where to do it ?
solana config set --url http://localhost:8899 (Is this enough to start the localhost ?)
solana-keygen new
solana-test-validator
I tried the above and got generated a keypair: keyname_1-keypair.json. The build went succesful but the deploy not !
I'm wondering why not ?
Hopefully some can guide me what to get it succed...
In a separate window / terminal, you need to run solana-test-validator so that the tools can talk to your local network. The error you're seeing on deployment is due to an error on connecting to that network.
By following the Solana docs and doing this
sudo $(command -v solana-sys-tuner) --user $(whoami) > sys-tuner.log 2>&1 &
https://docs.solana.com/running-validator/validator-start#system-tuning
The test-ledger folder is done and a sys-tuner.log file is created but it's 0 bytes...
Then i run the solana-test-validator in a separate terminal and the other solana config commands in another termianl then i get the following results ->
You can deploy on-chain programs with the Solana tools.
To deploy a program, you will need the location of the program's shared object.
It will return when you run anchor build in the command line.
Run solana program deploy <PROGRAM_FILEPATH>.
Successful deployment will return the program id of your program.

nginx configuration error: try to open a file which does not exist in sites-enabled

I tried to check the nginx configuration with
sudo nginx -t
output:
nginx: [emerg] open() "/etc/nginx/sites-enabled/django1" failed (2: No such file or directory) in /etc/nginx/nginx.conf:60
nginx: configuration file /etc/nginx/nginx.conf test failed
I once created django1 but I removed/deleted this project. Now Iam trying to start a new project but cannot solve this issue. I googled a lot and tried to change the nginx.conf file but without success. Does anyone know whats going wrong here?
Best
alex
You may have a softlink that pointed to your old project still.
Delete the /etc/nginx/sites-enabled/django1 file/softlink.

AWS Elastic Beanstalk how to get.ebextensions to write to /etc/httpd/conf.d/ the conf files inside?

Trying to add .conf files to /etc/httpd/conf.d/ directory on the E2 instance from elastic beanstalk during deployment of Elastic Beanstalk Application. I've added the .ebextensions directory with a .config file that is defined as follows:
files:
"/etc/php.d/project.ini" :
mode: "000644"
owner: root
group: root
content: |
max_input_vars = 10000
upload_max_filesize = 256M
post_max_size = 256M
container_commands:
01_enable_mod_deflate:
command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
02_enable_mod_expires:
command: "cp .ebextensions/enable_mod_expires.conf /etc/httpd/conf.d/enable_mod_expires.conf"
03_secure_wordpress:
command: "cp .ebextensions/secure_wordpress.conf /etc/httpd/conf.d/secure_wordpress.conf"
04_restart_apache:
command: "sudo apachectl restart"
the .conf files are all in the .ebextensions folder, but they are not getting copied over, which is causing an issue with .htaccess in the root of the wordpress site. The error that is being generated looks like this:
Command 01_enable_mod_deflate (cp /var/app/current/.ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf) failed
2020-10-05 13:45:59,944 [ERROR] Error encountered during build of postbuild_0_Benefits_Bridge_2: Command 01_enable_mod_deflate failed
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
changes['commands'] = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
raise ToolError(u"Command %s failed" % name)
ToolError: Command 01_enable_mod_deflate failed
Not sure what any of that even means, but it's generating the same error for each file. What is wrong here? I just spun up a new instance of Elastic Beanstalk and shouldn't this work by default? Is there an issue with the Instance or something? The site is generating a 500 error because of the .htaccess file in the root, but if I remove it, than only the homepage loads and all other pages give 404 errors. I need these .conf files added to the /etc/httpd/conf.d/ directory of all instances, but they aren't added at all to any of the instances because of the error above, which I have no idea how to fix, or if this is an issue with the instance which is the default that gets created with Elastic Beanstalk?
How to fix this problem? I've restarted the Environment, but that didn't help. I'm a bit hestitant to Rebuild the Environment since that will wipe out the database that is connected to the application and not sure if that would help any.
You are probably using Amazon Linux 2 that changed the location of configuration files for proxy (NGINX or Apache).
Put your proxy configuration files under .platform instead of .ebextensions:
Ex:
|____wp-signup.php
|____.platform
| |____httpd
| | |____conf.d
| | | |____http-redirect.conf
More details in the documentation:
Migrating your Elastic Beanstalk Linux application to Amazon Linux 2

How do deal with conan server connection refused?

I have a docker container which runs as Conan server. I am trying to upload some Conan packages from another docker container to conan server. After entering username and passwd I am getting following error
Error uploading file: conanmanifest.txt,
'HTTPConnectionPool(host='localhost', port=9300): Max retries exceeded with url: /v1/files/hello/0.1/demo/testing/0/export/conanmanifest.txt?signature=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZV9wYXRoIjoiaGVsbG8vMC4xL2RlbW8vdGVzdGluZy8wL2V4cG9ydC9jb25hbm1hbmlmZXN0LnR4dCIsInVzZXJuYW1lIjoiZGVtbyIsImZpbGVzaXplIjo1OCwiZXhwIjoxNTg1NDQyMjYyfQ.7sHncjZ7J8gV5HENMqCIwLe7b483QfrGJ2PVyolvjC4
(Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f99c84d2e50>:
Failed to establish a new connection: [Errno 111] Connection refused'))'
ERROR: hello/0.1#demo/testing: Upload recipe to 'my_server' failed: Execute upload again to retry upload the failed files: conanfile.py, conanmanifest.txt. [Remote: my_server]
ERROR: Errors uploading some packages
I ran the following command
docker run -t -p 9300:9999 --name mycont my_conan
then edited server.conf file accordingly
port:9300
public_port:9999
host_name: containerIP
From now on I expect to reach by curl http://localhost:9999 but getting
Failed to connect to localhost port 9999: Connection refused
PS: From my host to the server, it works perfectly fine. Bu the error is appearing when i want to upload from container to container
I solve it by copying a custom config file to docker container. Otherwise I could not override default config file.
1. Write custom config file
2. COPY or ADD to image (in Dockerfile)
3. mv custom.conf /path/to/directory/ (from entrypoint)

Fab Deploy Error: '"Error log: [emerg] 8780#0: invalid server name or wildcard "mydomain*.mydomain.com" on 0.0.0.0:80"'

I've been stuck on this deployment error for days, help! Our project is in the last step of deployment cd to the /home/django/django_project directory and run "fab deploy". Our project errors out on the supervisorctl start my_app: gunicorn command within our "fabfile.py" with the follow error code.:
"[555.555.55.555] out: my_app:gunicorn_my_app: ERROR (abnormal termination) "
Below are error logs.
/home/django/django_project/deploy
:: Important configuration files in this directory **nginx.conf**
/etc/supervisor/conf.d
:: Important configuration files in this directory **my_app.conf**
/var/log/supervisor
:: Important error log files in this directory **supervisord.log**
"INFO spawned: 'gunicorn_my_app' with pid 11575
INFO exited: gunicorn_my_app (exit status 1; not expected)
INFO gave up: gunicorn_my_app entered FATAL state, too many start retries too quickly"
/var/log/nginx
:: Important error log files in this directory **error.log.1**
Error log: 2015/01/02 18:21:42 [emerg] 8780#0: invalid server name or wildcard "mydomain*.mydomain.com" on 0.0.0.0:80
I changed the server name variable in our nginx.conf file but for some reason it hasn't been updated when this command runs.
I probably can't help, but I'll throw some things out there.
You haven't provided any of your configs for nginx or gunicorn, which would be helpful. Perhaps you could provide those so others can take a look at them?
Gunicorn:
From the logs it seems like gunicorn is taking a poop somewhere in the process of attempting to launch. Perhaps a configuration error may be preventing the server from starting. If you haven't done so yet it's worth checking that your configs are kosher.
From the gunicorn configuration documentation:
To check your configuration when using the command line or the configuration file you can run the following command:
$ gunicorn my_app:gunicorn_my_app --check-config
It will also allow you to know if your application can be launched.
If everything comes back fine, then you can probably rule that out and take a deeper look. Gunicorn has a debug option that should let you see in great detail what exactly is going wrong. The docs say it can be done with the --debug option, like so:
$ gunicorn my_app:gunicorn_my_app --debug
Hopefully that should get you a little closer to understanding what's up.
Nginx:
I don't know if you're getting that nginx error every time you're trying to start the server, but I'll take a stab at what I can see in that error log.
Nginx only supports wildcard server names at beginning or the end of the name.
From the nginx documentation on server names:
A wildcard name may contain an asterisk only on the name’s start or end, and only on a dot border. The names “www..example.org” and “w.example.org” are invalid. However, these names can be specified using regular expressions, for example, “~^www..+.example.org$” and “~^w..example.org$”. An asterisk can match several name parts. The name “.example.org” matches not only www.example.org but www.sub.example.org as well.
To listen on mydomain*.mydomain.com, you would use a regular expression in the server_name directive in the server block of your nginx.conf file.
The following regular expression would achieve this:
^mydomain(\S*)\.mydomain\.com$
and you would put it in your nginx.conf like so:
server {
server_name ~^mydomain(\S*)\.mydomain\.com$;
}
And after saving any changes to your nginx.conf, always running this command is good practice:
$ sudo nginx -t
Just like gunicorn's --check-config, it parses your configuration files to check that there are no errors, and it will tell you if there are any that need fixing.
Apologies if this answer isn't ultimately useful.