Join the community today
Register Now

www appears to redirect to another on the same server

Discussion in 'AlmaLinux 8 & Rocky Linux 8 Beta Testing' started by cloud9, Aug 29, 2023.

  1. cloud9

    cloud9 Premium Member Premium Member

    425
    117
    43
    Oct 6, 2015
    England
    Ratings:
    +217
    Local Time:
    8:51 AM
    1.25.3
    10.6.x
    The following test environment information is needed relevant to your EL8 server installation. Please provide the info in BBCODE CODE/CODEB tags for better formatting.

    1. Hetzner VPS CPX31
    2. Centmin Mod installed version info via command below:

    cminfo versions
    1st:
    130.00beta01.b277 #Fri Mar 17 20:00:09 UTC 2023
    ..
    last 10:
    130.00beta01.b368 #Fri Jul 7 13:31:07 UTC 2023
    130.00beta01.b370 #Fri Jul 7 13:47:23 UTC 2023
    130.00beta01.b370 #Fri Jul 7 14:28:16 UTC 2023
    130.00beta01.b371 #Sun Jul 9 11:56:25 UTC 2023
    130.00beta01.b372 #Wed Jul 12 12:11:03 UTC 2023
    130.00beta01.b375 #Thu Aug 3 18:51:19 UTC 2023
    130.00beta01.b375 #Thu Aug 3 19:21:12 UTC 2023
    130.00beta01.b376 #Tue Aug 8 15:51:15 UTC 2023
    130.00beta01.b376 #Sat Aug 19 17:00:53 UTC 2023
    130.00beta01.b383 #Mon Aug 28 19:03:38 UTC 2023

    3. Provide CPU, memory and disk info via these 3 commands below:

    lscpu
    Architecture: x86_64
    CPU op-mode(s): 32-bit, 64-bit
    Byte Order: Little Endian
    CPU(s): 2
    On-line CPU(s) list: 0,1
    Thread(s) per core: 1
    Core(s) per socket: 2
    Socket(s): 1
    NUMA node(s): 1
    Vendor ID: GenuineIntel
    BIOS Vendor ID: QEMU
    CPU family: 6
    Model: 85
    Model name: Intel Xeon Processor (Skylake, IBRS)
    BIOS Model name: NotSpecified
    Stepping: 4
    CPU MHz: 2294.614
    BogoMIPS: 4589.22
    Hypervisor vendor: KVM
    Virtualization type: full
    L1d cache: 32K
    L1i cache: 32K
    L2 cache: 4096K
    L3 cache: 16384K
    NUMA node0 CPU(s): 0,1
    Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat pku ospke md_clear
    free -mlt

    Code:
                  total        used        free      shared  buff/cache   available
    Mem:           3635        1243         755         113        1636        1999
    Low:           3635        2880         755
    High:             0           0           0
    Swap:          1023         481         542
    Total:         4659        1725        1297
    df -hT


    Code:
    Filesystem     Type      Size  Used Avail Use% Mounted on
    devtmpfs       devtmpfs  1.8G     0  1.8G   0% /dev
    tmpfs          tmpfs     1.8G     0  1.8G   0% /dev/shm
    tmpfs          tmpfs     1.8G  193M  1.6G  11% /run
    tmpfs          tmpfs     1.8G     0  1.8G   0% /sys/fs/cgroup
    /dev/sda1      ext4       38G   14G   23G  38% /
    /dev/sda14     vfat       64M  5.8M   59M  10% /boot/efi
    tmpfs          tmpfs     364M     0  364M   0% /run/user/0
    /dev/loop0     ext4      3.9G  108K  3.7G   1% /tmp
    4. standard almalinux 8 install - latest php and nginx - recently in the last week upgraded from 25.1 to 25.2


    Have 10 Wordpress websites running - all good and nothings changed in the last 2 weeks apart from cmupdates and yum updates and upgrading nginx

    one website now points to the first one on the server

    ie

    A website 1
    B website 2
    C website 3
    D E F G H etc to website 10

    All websites work apart from B
    Going to https:// website 2 goes to website 1

    However if I go to https:// website 2/wp-admin for the Wordpress back end then it goes to the correct wp-admin for website 2


    Very strange
     
  2. eva2000

    eva2000 Administrator Staff Member

    52,749
    12,077
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,604
    Local Time:
    5:51 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Are these sites all behind Cloudflare orange clouded enabled proxy? Might need to see the Nginx vhost configurations too. Did you use HTTPS default selection when creating Nginx vhosts?

    Posted at centminmod.com/nginx_domain_dns_setup.html#httpsredirect is the correct way to set it up - pay attention to different way if you want redirect target being www version instead of non-www and vice versa and that the target version www or non-www is the only version listed in server_name for the 2nd/main server {} context.

    If you prefer www domain i.e. https://wwww.newdomain.com to be the intended redirect target, you will have add a 3rd server{} context to your Nginx HTTPS SSL vhost config file as outlined here.

    Code (Text):
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    # For HTTP/2 SSL Setup
    # read http://centminmod.com/nginx_configure_https_ssl_spdy.html
    
    # redirect from www to non-www  forced SSL
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
     server {
       server_name newdomain.com www.newdomain.com;
       return 302 https://www.newdomain.com$request_uri;
     }
    
    server {
      listen 443 ssl http2;
      server_name newdomain.com;
      return 302 https://www.newdomain.com$request_uri;
    
      ssl_dhparam /usr/local/nginx/conf/ssl/newdomain.com/dhparam.pem;
      ssl_certificate      /usr/local/nginx/conf/ssl/newdomain.com/newdomain.com.crt;
      ssl_certificate_key  /usr/local/nginx/conf/ssl/newdomain.com/newdomain.com.key;
      include /usr/local/nginx/conf/ssl_include.conf;
    }
    
    server {
      listen 443 ssl http2;
      server_name www.newdomain.com;
    
      ssl_dhparam /usr/local/nginx/conf/ssl/newdomain.com/dhparam.pem;
      ssl_certificate      /usr/local/nginx/conf/ssl/newdomain.com/newdomain.com.crt;
      ssl_certificate_key  /usr/local/nginx/conf/ssl/newdomain.com/newdomain.com.key;
      include /usr/local/nginx/conf/ssl_include.conf;
    
    < snipped the rest of the nginx settings >

    Notice the middle server{} context tells Nginx to redirect non-www domain HTTPS requests to www domain HTTPS requests for www domain on third server{} context. While first server{} context tells Nginx to redirect both non-HTTPS non-www and www domain requests to HTTPS requests for www domain on third server{} context.

    key to testing is using 302 temp redirect first in a private incognito browser session otherwise the problems you can experience may end up being due to browser caching or 301 permanent redirects unless you clear browser cache and reboot local computer(s) and even then some web browsers don't let go of 301 permanent redirect browser cache that willingly :)

    For each of your 3 sites, you can test in SSH via curl to check headers for location field (where the redirect goes) using the following 4 commands for each site:
    Code (Text):
    curl -I http://domain.com
    

    Code (Text):
    curl -I http://www.domain.com
    

    Code (Text):
    curl -I https://domain.com
    

    Code (Text):
    curl -I https://www.domain.com
    
     
  3. OscarS

    OscarS New Member

    2
    1
    3
    Nov 7, 2016
    Ratings:
    +1
    Local Time:
    2:51 AM
    This happened to me a few months ago it may not be related to CMM (I was using vanilla) and the issue was that the cert expired and due to the lacks of http vhost it was redirected to the default vhost. So probably your issue is something like that.
     
  4. cloud9

    cloud9 Premium Member Premium Member

    425
    117
    43
    Oct 6, 2015
    England
    Ratings:
    +217
    Local Time:
    8:51 AM
    1.25.3
    10.6.x
    Sorry been busy

    Answer NO

    Yes and the sites have been working fine for a number of months - something - update cmm / AlmaLinux or maybe domain (or though its in my customers account and he hasn't hanged anything)

    This is the problem site

    Code:
    [17:07][root@alma.server.com domains]# curl curl -I http://problemwebsite.co.uk
    curl: (6) Could not resolve host: curl
    HTTP/1.1 302 Moved Temporarily
    Date: Tue, 26 Sep 2023 17:10:10 GMT
    Content-Type: text/html
    Content-Length: 138
    Connection: keep-alive
    Location: https://problemwebsite.co.uk/
    Server: nginx centminmod
    X-Powered-By: centminmod
    This is a good website

    Code:
    [17:10][root@alma.server.com domains]# curl curl -I http://goodwebsite.co.uk
    curl: (6) Could not resolve host: curl
    HTTP/1.1 302 Moved Temporarily
    Date: Tue, 26 Sep 2023 17:12:40 GMT
    Content-Type: text/html
    Content-Length: 138
    Connection: keep-alive
    Location: https://goodwebsite.co.uk/
    Server: nginx centminmod
    X-Powered-By: centminmod
    problem website

    Code:
    [17:13][root@alma.server.com domains]# curl curl -I https://problemwebsite.co.uk
    curl: (6) Could not resolve host: curl
    HTTP/2 200
    date: Tue, 26 Sep 2023 17:13:44 GMT
    content-type: text/html; charset=UTF-8
    vary: Accept-Encoding
    x-pingback: https://abertawe-engineering.co.uk/xmlrpc.php
    link: <https://problemwebsite.co.uk/wp-json/>; rel="https://api.w.org/"
    link: <https://problemwebsite.co.uk/wp-json/wp/v2/pages/546>; rel="alternate"; type="application/json"
    link: <https://problemwebsite.co.uk/>; rel=shortlink
    server: nginx centminmod
    x-powered-by: centminmod
    x-cache: MISS
    x-cache-2: BYPASS
    x-xss-protection: 1; mode=block
    x-content-type-options: nosniff
    
    Good Website

    Code:
    [17:12][root@alma.server.com domains]# curl curl -I https://goodwebsite.co.uk
    curl: (6) Could not resolve host: curl
    HTTP/2 200
    date: Tue, 26 Sep 2023 17:13:36 GMT
    content-type: text/html; charset=UTF-8
    vary: Accept-Encoding
    link: <https://goodwebsite.uk/wp-json/>; rel="https://api.w.org/"
    link: <https://goodwebsite.co.uk/wp-json/wp/v2/pages/55>; rel="alternate"; type="application/json"
    link: <https://goodwebsite.co.uk/>; rel=shortlink
    server: nginx centminmod
    x-powered-by: centminmod
    x-cache: MISS
    x-cache-2: BYPASS
    x-xss-protection: 1; mode=block
    x-content-type-options: nosniff
    Interestingly in a private browser window - the site appears fine
     
  5. pjrobertson

    pjrobertson New Member

    20
    4
    3
    Feb 7, 2021
    Ratings:
    +8
    Local Time:
    5:51 PM
    I see curl is using IPv6. Could that be the issue - not setting up IPv6 correctly. Try with
    Code:
    curl -4 
    https://problemwebsite.co.uk
    ?
     
  6. cloud9

    cloud9 Premium Member Premium Member

    425
    117
    43
    Oct 6, 2015
    England
    Ratings:
    +217
    Local Time:
    8:51 AM
    1.25.3
    10.6.x
    Im not using IPv6
     
  7. eva2000

    eva2000 Administrator Staff Member

    52,749
    12,077
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,604
    Local Time:
    5:51 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Are all 10x Wordpress installs installed using centmin.sh menu option 22 with Redis Nginx level caching? What's output for command
    Code (Text):
    redis-cli info
    

    also what's contents of Wordpress redis PHP include file /usr/local/nginx/conf/php-rediscache.conf
    Code (Text):
    cat /usr/local/nginx/conf/php-rediscache.conf


    Tried clearing your browser cache?
     
  8. cloud9

    cloud9 Premium Member Premium Member

    425
    117
    43
    Oct 6, 2015
    England
    Ratings:
    +217
    Local Time:
    8:51 AM
    1.25.3
    10.6.x
    Yes



    Code:
    redis-cli info
    # Server
    redis_version:6.2.13
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:eb817d752e3c8db8
    redis_mode:standalone
    os:Linux 4.18.0-425.13.1.el8_7.x86_64 x86_64
    arch_bits:64
    monotonic_clock:POSIX clock_gettime
    multiplexing_api:epoll
    atomicvar_api:c11-builtin
    gcc_version:8.5.0
    process_id:2086779
    process_supervised:systemd
    run_id:6d389bf0c9a8f60e3832bff559c0139d371efaa4
    tcp_port:6379
    server_time_usec:1697831651563213
    uptime_in_seconds:8667739
    uptime_in_days:100
    hz:10
    configured_hz:10
    lru_clock:3332835
    executable:/usr/bin/redis-server
    config_file:/etc/redis/redis.conf
    io_threads_active:0
    
    # Clients
    connected_clients:3
    cluster_connections:0
    maxclients:10000
    client_recent_max_input_buffer:32
    client_recent_max_output_buffer:0
    blocked_clients:0
    tracking_clients:0
    clients_in_timeout_table:0
    
    # Memory
    used_memory:50292664
    used_memory_human:47.96M
    used_memory_rss:50933760
    used_memory_rss_human:48.57M
    used_memory_peak:128913808
    used_memory_peak_human:122.94M
    used_memory_peak_perc:39.01%
    used_memory_overhead:1019640
    used_memory_startup:812064
    used_memory_dataset:49273024
    used_memory_dataset_perc:99.58%
    allocator_allocated:50578384
    allocator_active:54001664
    allocator_resident:58892288
    total_system_memory:3812286464
    total_system_memory_human:3.55G
    used_memory_lua:55296
    used_memory_lua_human:54.00K
    used_memory_scripts:232
    used_memory_scripts_human:232B
    number_of_cached_scripts:1
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    allocator_frag_ratio:1.07
    allocator_frag_bytes:3423280
    allocator_rss_ratio:1.09
    allocator_rss_bytes:4890624
    rss_overhead_ratio:0.86
    rss_overhead_bytes:-7958528
    mem_fragmentation_ratio:1.01
    mem_fragmentation_bytes:704816
    mem_not_counted_for_evict:0
    mem_replication_backlog:0
    mem_clients_slaves:0
    mem_clients_normal:41024
    mem_aof_buffer:0
    mem_allocator:jemalloc-5.1.0
    active_defrag_running:0
    lazyfree_pending_objects:0
    lazyfreed_objects:0
    
    # Persistence
    loading:0
    current_cow_size:0
    current_cow_size_age:0
    current_fork_perc:0.00
    current_save_keys_processed:0
    current_save_keys_total:0
    rdb_changes_since_last_save:86
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1697830501
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    rdb_last_cow_size:1163264
    aof_enabled:0
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:-1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_last_cow_size:0
    module_fork_in_progress:0
    module_fork_last_cow_size:0
    
    # Stats
    total_connections_received:661154
    total_commands_processed:5164634
    instantaneous_ops_per_sec:0
    total_net_input_bytes:49858620617
    total_net_output_bytes:105437181181
    instantaneous_input_kbps:0.00
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:0
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:11449
    expired_stale_perc:0.00
    expired_time_cap_reached_count:0
    expire_cycle_cpu_milliseconds:644088
    evicted_keys:0
    keyspace_hits:4157878
    keyspace_misses:350436
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:3466
    total_forks:5272
    migrate_cached_sockets:0
    slave_expires_tracked_keys:0
    active_defrag_hits:0
    active_defrag_misses:0
    active_defrag_key_hits:0
    active_defrag_key_misses:0
    tracking_total_keys:0
    tracking_total_items:0
    tracking_total_prefixes:0
    unexpected_error_replies:0
    total_error_replies:31539
    dump_payload_sanitizations:0
    total_reads_processed:8507176
    total_writes_processed:5049485
    io_threaded_reads_processed:0
    io_threaded_writes_processed:0
    
    # Replication
    role:master
    connected_slaves:0
    master_failover_state:no-failover
    master_replid:584b31d34dcae960de81a8e9a1bf035b3d54c52e
    master_replid2:0000000000000000000000000000000000000000
    master_repl_offset:0
    second_repl_offset:-1
    repl_backlog_active:0
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:0
    repl_backlog_histlen:0
    
    # CPU
    used_cpu_sys:10733.072602
    used_cpu_user:11615.555775
    used_cpu_sys_children:336.234747
    used_cpu_user_children:1709.832333
    used_cpu_sys_main_thread:10676.213831
    used_cpu_user_main_thread:11574.507927
    
    # Modules
    
    # Errorstats
    errorstat_ERR:count=31539
    
    # Cluster
    cluster_enabled:0
    
    # Keyspace
    db0:keys=3324,expires=14,avg_ttl=85576284
    Code:
    location ~ [^/]\.php(/|$) {
      include /usr/local/nginx/conf/503include-only.conf;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }
    
        set $key "nginx-cache:$scheme$request_method$host$request_uri$http_accept_encoding";
        srcache_fetch_skip $skip_cache;
        srcache_store_skip $skip_cache;
        srcache_response_cache_control off;
        set_escape_uri $escaped_key $key;
        srcache_fetch GET /redis-fetch $key;
        srcache_store PUT /redis-store key=$escaped_key;
        more_set_headers 'X-Cache $srcache_fetch_status';
        more_set_headers 'X-Cache-2 $srcache_store_status';
    
        fastcgi_pass   127.0.0.1:9000;
        #fastcgi_pass   unix:/run/php-fpm//php-fpm.sock;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME    $request_filename;
        #fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;
    
    # might shave 200+ ms off PHP requests
    # which don't pass on a content length header
    # slightly faster page response time at the
    # expense of throughput / scalability
    #sendfile on;
    #tcp_nopush off;
    #keepalive_requests 0;
    
    fastcgi_connect_timeout 360s;
    fastcgi_send_timeout 360s;
    fastcgi_read_timeout 360s;
    fastcgi_buffer_size 32k;
    fastcgi_buffers 512 32k;
    fastcgi_busy_buffers_size 1m;
    fastcgi_temp_file_write_size 4m;
    fastcgi_max_temp_file_size 4m;
    fastcgi_intercept_errors off;
    
    # next 3 lines when uncommented / enabled
    # allow Nginx to handle uploads which then
    # passes back the completed upload to PHP
    #fastcgi_pass_request_body off;
    #client_body_in_file_only clean;
    #fastcgi_param  REQUEST_BODY_FILE  $request_body_file;
    
    #new .04+ map method
    fastcgi_param HTTPS $server_https;
    
    # comment out PATH_TRANSLATED line if /usr/local/lib/php.ini sets following:
    # cgi.fix_pathinfo=0
    # as of centminmod v1.2.3-eva2000.01 default is set to cgi.fix_pathinfo=1
    
    fastcgi_param  PATH_INFO          $fastcgi_path_info;
    fastcgi_param  PATH_TRANSLATED    $document_root$fastcgi_path_info;
    
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;
    
    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;
    fastcgi_param  REQUEST_SCHEME     $scheme;
    fastcgi_param  HTTPS              $https if_not_empty;
    fastcgi_param  HTTP_PROXY         "";
    
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
    
    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;
    
    # Set php-fpm geoip variables
    fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
    fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
    fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
    fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code;
    fastcgi_param GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3;
    fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name;
    fastcgi_param GEOIP_REGION $geoip_region;
    fastcgi_param GEOIP_CITY $geoip_city;
    fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
    fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
    fastcgi_param GEOIP_LATITUDE $geoip_latitude;
    fastcgi_param GEOIP_LONGITUDE $geoip_longitude;
    
    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;
    
                       }