nginx proxy_pass to another server/path/

I have 2 Ubuntu 16.04 servers: one reverse proxy server (has public IP and local IP and one web server (has only local IP

On reverse proxy server I installed nginx, and configured it as follow:

server {
        listen 80;
        #listen [::]:80 ipv6only=on;


        return 301 https://$host$request_uri;

server {
        listen 443;

        ssl on;
        # Use certificate and key provided by Let's Encrypt:
        ssl_certificate /etc/letsencrypt/live/;
        ssl_certificate_key /etc/letsencrypt/live/;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

        location / {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://192.168.x.x/wordpress/;
                proxy_ssl_session_reuse off;
                proxy_set_header Host $http_host;
                proxy_cache_bypass $http_upgrade;
                proxy_redirect off;


On web server I installed LEMP stack. The content of /etc/nginx/sites-available/default is:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm;
    server_name _;
    location / {
        try_files $uri $uri/ =404;
    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    location ~ /.ht {
        deny all;

Because I want serve more website on one web server such as is at /opt/wordpress1/ , is at /opt/wordpress2/
so I made symbolic links and changed owner of these directories to www-data

sudo ln -s /opt/wordpress/ /var/www/html/
sudo chown -R www-data:www-data /opt/wordpress1/
sudo chown -R www-data:www-data /var/www/html/

However, when I go to, it goes to
and the result is 404 Not Found nginx/1.10.0 (Ubuntu).

How can I fix this problem?

Read more here: nginx proxy_pass to another server/path/

Leave a Reply

Your email address will not be published. Required fields are marked *