I started an nginx container and would like to modify the content of the default page.
I changed the file /usr/share/nginx/html/index.html
Unfortunately nginx still shows me the usual welcome page when I curl localhost.
How would I change the default page in nginx?
I disabled cache in nginx via sendfile off;
Probably you did something like this in your Dockerfile:
COPY ./index.html /usr/share/nginx/html/index.html
Try this instead:
COPY ./index.html /usr/share/nginx/html/
Related
I'm using Magento 2.4 and when I'm trying to connect to my Magento 2 domain on localhost, I get the default Nginx page.
This is the Nginx conf file in /etc/nginx/sites-available and I created a soft link of this file in the /etc/nginx/sites-enabled directory
upstream fastcgi_backend {
server unix:/run/php/php7.4-fpm.sock;
}
server {
listen 80;
server_name www.edu.ubuntu.com;
set $MAGE_ROOT /var/www/project-community-edition;
set $MAGE_MODE developer;
include /var/www/project-community-edition/nginx.conf.sample;
}
I added this to /etc/hosts file
127.0.0.1 edu.ubuntu.com
This is my web/unsecure/base_url in the core_config_data
http://edu.ubuntu.com/
But I'm still getting Nginx default page when I'm trying to enter http://edu.ubuntu.com. Could anyone help me? Any kind of help would be appreciated
Looks like default conf file was also listening to 80. I just moved that file away from there and everything works now.
127.0.0.1 edu.ubuntu.com
Remove this line in etc/hosts
then run sudo service nginx restart
I've tried the same installation of PrestaShop (ver 1.7.5.1) with Apache and nginx (copying the nginx installation into Apache root dir).
When I surf on admin panel I see urls like this:
http://localhost/admin825pqjv9z/index.php/configure/advanced/system-information/?_token=lJz8rH0rLWJJsrgY6tC97KuCrniEs2eps41UEoU5vqY
where index.php is concatenated with the rest of the url
When I use Apache every work fine however with Nginx, I'm getting redirected.
I've tried the following nginx configuration for PrestaShop:
https://gist.github.com/vicobits/86804fa5f6bd9e2a38f353518563590f
but it did not worked.
I just tried the example you provided on my nginx install and it went well.
Did you replace /admin-dev/ by your own admin folder name /admin825pqjv9z/? You should have:
location /admin825pqjv9z/ { # Change this for your admin url
if (!-e $request_filename) {
rewrite ^/.*$ /admin825pqjv9z/index.php last;
}
}
I hope this helps, otherwise I'd be happy to check other options with you.
I'm using Docker to serve my simple WordPress website. A nginx container and a wordpress container. Simple setup:
upstream wordpress_english {
server wordpress_en:80;
}
server {
listen 80;
server_name my_domain.com www.my_domain.com;
location / {
proxy_pass http://wordpress_english;
}
}
Problem: Static files (css, js and images) are not loaded.
The output from the browser console shows a 404:
http://wordpress_english/wp-content/themes/twentyfifteen/genericons/genericons.css?ver=3.2
Its easy to spot the problem: The browser looks for the static files at wordpress_english (the nginx upstream name), instead of my_domain.com
How can I fix this problem?
This is not a nginx problem, but a WordPress problem.
Solution:
In wp-config.php, add the following two lines:
define('WP_HOME','http://my_domain.com');
define('WP_SITEURL','http://my_domain.com');
During the WordPress installation, WordPress automatically sets WP_HOME to nginx upstream name. The above solution overwrites the default setting.
Seems to be an issue in your nginx config file.
When declaring your server my_domain you provide location / with proxy_pass wordpress_english. I don't know a lot on nginx, but I don't see any declaration of path in your server my_domain and is root is linked to wordpress_english. Seems normal that he is looking for files in wordpress_english and not in you server. (In fact, I guess he is looking in your server but your server tells to look in wordpress).
Not sure about it cause I don't know well nginx and proxy_pass functions.
With the Synology DSM6 update, we have now to use Nginx instead of Apache. By default Nginx configuration don't allow wordpress permalinks (generate 404).
I read the idea was to transform the /uri in /?p=$uri and put this configuration in the "location" section of the server nginx config.
Where to put this configuration in DSM6 exactly ?
Have you tried the user config? Just copy your working:
/etc/nginx/app.d/server.webstation-vhost.conf
to:
/usr/local/etc/nginx/sites-enabled/httpd-vhost.conf-user
and rename the server.webstation-vhost.conf to server.webstation-vhost.conf.old or something and restart nginx (nginx -s reload)
Or better yet, remove your virtual host(s) from webstation. Only thing is you need to manually update your SSL certs when they expire instead of using the web interface.
Actually, you can add custom directives easily, without modifying the DSM behavior.
Take a look at the content of /usr/local/etc/nginx/sites-enabled/httpd-vhost.conf-user, to see where the custom configuration has to be stored:
server {
[...]
server_name NAME
[...]
include /usr/local/etc/nginx/conf.d/778943ad-0dc4-40ae-bb7f-7b2285e3203b/user.conf*;
}
Then, you just have to create the file /usr/local/etc/nginx/conf.d/778943ad-0dc4-40ae-bb7f-7b2285e3203b/user.conf.wordpress-permalink with the following content:
location /{
try_files $uri $uri/ /index.php?$args;
}
and restart nginx:
synoservicecfg --restart nginx
It will not break the future DSM update (since it is a supported customization)
I have a flask app running with gunicorn and nginx on Ubuntu 14.04 using AWS EC2. I have deleted default site from /etc/nginx/sites-available and /etc/nginx/sites-enabled. In those two folders, there is only one file: flasky - my nginx file as below:
server {
listen 80;
location / {
include proxy_params;
proxy_pass http://unix:/tmp/flasky.sock;
}
When I enter the IP of the server in the browser, the default Nginx static page shows up. If I go to /auth/login, the correct page served by Flask shows up properly.
If the change the port from 80 to 8080, restart Nginx, enter http://ip-address:8080 then all Flask pages work well. I don't know how to fix this for port 80. Please help! Thanks!
UPDATE: I just found out that if I use the AWS Public DNS: http://ec2-50-112-125-180.us-west-2.compute.amazonaws.com, it works. But if I use the corresponding Elastic IP: 50.112.125.180 it shows the nginx default page. Anyone knows why?
Search your nginx.conf for the word include
maybe it's including other directories for config files.
Also, there may be other config blocks with
location /
that is superseding this section that also have listen 80.